Simulate poor network connection on android [duplicate] - android
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I would like to test my application for cases of low network connectivity. Except standing in the elevator, what is the best way to do this? I've tried wrapping my phone in an aluminum foil, but it didn't help much.
I need to test it on a real device, not in an emulator.
This may sound a little crazy, but a microwave oven serves as a microwave shield. Therefore, putting your device inside a microwave oven (DO NOT turn on the microwave oven while your device is inside!) will cause your signal strength to drop significantly. It definitely beats standing inside an elevator...
You can use emulator for this. Take a look at this page: Android Emulator. Pay attention to next two arguments:
-netdelay <delay>
Set network latency emulation to . Default value is none. See
the table in Network Delay Emulation for supported values.
-netspeed <speed>
Set network speed emulation to . Default value is full. See
the table in Network Speed Emulation for supported values.
Speeds for reference in increasing kbps:
UP DOWN
-------- ----------
gsm GSM/CSD 14.4 14.4
hscsd HSCSD 14.4 57.6
gprs GPRS 28.8 57.6
umts UMTS/3G 384.0 384.0
edge EDGE/EGPRS 473.6 473.6
hsdpa HSDPA 5760.0 13,980.0
lte LTE 58,000.0 173,000.0
evdo EVDO 75,000.0 280,000.0
full No limit ∞ ∞
Since iPhones developer option apply on wifi tethering, you can get an iPhone which has iOS 6 and above (and has been set to use for developments with the xcode), set it to emulate the desired network profile, connect your Android device to its hotspot
Update for Android Studio v 1.5 or greater
As #LouMorda mentioned in a comment below that the Emulator tab mentioned in original post has been removed in Android Studio v 1.5.
Now They've placed these settings in Simulator Settings in AVD Manager.
To access these settings:
Select Tools -> Android -> AVD Manager
Click the Edit AVD button (pencil icon)
The Network Settings can be accessed after clicking the Show Advanced Settings button
Here is a screenshot of how it may appear:
Original Post
For anyone using Android Studio IDE:
Go to Run -> Edit Configurations
Select Android Application -> [Your App]
Select Emulator tab
Here you can change different values for Network Speed(internet speed) and Network Latency (delay) to simulate different speeds and latencies etc
Alternatively, you can enter various arguments in Additional command line options text field as mentioned in #inazaruk's answer.
The screenshot below describes how this Run Configuration screen looks like:
I know its a bit late to answer to this question, but i hope this helps others facing similar issues!
Edit
For anyone using eclipse, see #Abhi's answer below.
I know it's an old question but...
Some phones nowadays have a setting to utilize 2G only. It's perfect for simulating slow internet on a real device.
Years old but hey, I'll chime in with my foolproof method with Genymotion.
Download the Charles free trial: http://www.charlesproxy.com/download/
Install it
ClickProxy -> Throttle Settings
Set up your HTTP throttled speeds
Close that window
Click Proxy -> Throttling to enable the throttle
Open up a Genymotion emulator
Open the wifi settings
Long press the enabled wifi connection
Click Modify Network
Click Show Advanced Options
Set Proxy to Manual
Set the Proxy hostname to 10.0.3.2
Set the Port to 8888
Click Save
And now your network will be throttled!
I have one strategy to settle your problem. You can use the application of proxy to modify or monitor your net status. e.g, Charles.
You ought to change the default config of the Charles like the following picture I posted.
And finally, you will discover the net status has been shaped into lower pace.
You are also able to test slow internet connectivity on an real android device:
Tested with Samsung Galaxy S8 + Android 8.0.0
Go to Settings -> Connection -> Mobile Network -> and under networkmode you can choose to only use 2G or 3G connections
In Android Studio, while running an emulator:
1- Hit settings button at the bottom of the emulator sidebar
2- Go to Cellular
3- Set Network Type
Easy way to test your application with low/bad connection in emulator:
Go Run > Run configurations, select your Android Application, and there go to Target tab.
Look Emulator launch parameters. Here, you can easy modify Network Speed and Network Latency.
There's a simple way of testing low speeds on a real device that seems to have been overlooked. It does require a Mac and an ethernet (or other wired) network connection.
Turn on Wifi sharing on the Mac, turning your computer into a Wifi hotspot, connect your device to this. Use Netlimiter/Charles Proxy or Network Link Conditioner (which you may have already installed) to control the speeds.
For more details and to understand what sort of speeds you should test on check out: http://opensignal.com/blog/2016/02/05/go-slow-how-why-to-test-apps-on-poor-connections/
I'm surprised nobody mentioned this. You can tether via Bluetooth, and separate them by ten+ meters(or less with obstacles). You've got a real bad connection. No microwave, no elevator, no software needed.
Or on an actual device you can go to Settings -> Mobile Networks -> Preferred network types and chose the slowest available...
Of course this is very limited, but for some test- purposes it might be enough.
Facebook built something called Augmented Traffic Control. A brief summary from their GitHub page:
Augmented Traffic Control (ATC) is a tool to simulate network conditions. It allows controlling the connection that a device has to the internet. Developers can use ATC to test their application across varying network conditions, easily emulating high speed, mobile, and even severely impaired networks. Aspects of the connection that can be controlled include:
bandwidth
latency
packet loss
corrupted packets
packets ordering
In order to be able to shape the network traffic, ATC must be running on a device that routes the traffic and sees the real IP address of the device, like your network gateway for instance. This also allows any devices that route through ATC to be able to shape their traffic. Traffic can be shaped/unshaped using a web interface allowing any devices with a web browser to use ATC without the need for a client application.
You can find it here on GitHub: https://github.com/facebook/augmented-traffic-control
They have also written a blog post about it: https://code.facebook.com/posts/1561127100804165/augmented-traffic-control-a-tool-to-simulate-network-conditions/
UPDATE on the Android studio AVD:
open AVD manager
create/edit AVD
click advanced settings
select your preferred connectivity setting
No microwaves or elevators :)
for and mac OS user you can use Network Link Conditioner which could be downloaded from apple. set it as a AP on mac and any divices could connected it.
you can either use facebook open source tools ATC
http://facebook.github.io/augmented-traffic-control/
Go Run > Run configurations, select your Android Application, and there go to Target tab. Do changes as shown in the figure.
I was struggling with this problem for half a day, finally I came to this solution:
Testing on a real device doesn't make much sense overall as you have to go through a lot to make it work. The only logical way to achieve real testing is to make your phone connect to a low quality cellular network, like EDGE, if your phone company provides it. You can try to do this by dialing *#*#4636#*#* in the phone app
The original Android emulator is way too slow for testing and doesn't achieve more than the solution above.
The best way to do this is using Genymotion. It's an Android emulator with much better performance than the original AVDs and the version for personal use is free.
After you created your virtual device in Genymotion, just go through this tutorial to set a proxy for the device.
Run a proxy server on your host machine that simulates bad network conditions, like Crapify or Toxiproxy (I only tested the former) and you're good to go.
Update:
I just realized you can pick the very same strategy with real devices too. I feel like an idiot for not realizing it sooner. Just start a Crapify proxy on your computer, set your phone proxy to your computer's local address and voila, you've got crappy internet on your phone.
Do you want to test for no network connection, or just a slow network connection? If the former, you can go to Settings > Wireless & networks > Airplane mode and turn Airplane mode on. That will let you test network unavailability on an actual device.
as suggested by #VicVu Charles (or any other proxy tool) is an easier way to go. But I would Like to add that you can do this with your device also, not just genymotion or other emulators. Process will be the same:
Modify your device/emulator's wifi setting to use manual proxy. And then Set the Proxy hostname & port
a. set the hostname as ip of your system (get the ip of your pc/mac using ifconfig/ifconfig)
b. set the port number of genymotion (check the proxy settings in charles)
PS: Your device/emulator MUST be using the same wifi since the ip you are using will most probably be the private ip.
Open terminal inAndroid Studio and Go to ../../Android/sdk/tools. 'emulator' executable should be available here.
Run ./emulator -netdelay "delay_in_millis" -avd "emulator_device_name"
Ex: ./emulator -netdelay 60000 -avd Nexus_5_API_21
Now build your app and install it in emulator.
Run your scenario in app.
Make sure you have your code changes in app that sets timeout to your request and handles that.
Just go to Android device monitor from Android studio , then DDMS -> Emulator Control.There will be Speed and Latency properties.
I found netlimiter4 to be the best solution for throttling data to emulators.
It provides for granular control through a decent gui and gives you graphical feedback on the data throughput to each process. Currently in a free beta.
screenshot
http://www.netlimiter.com/products/nl4
There are apps available on the play store to throttle to actual devices but they require root(I cant provide any advice as to how well they work, if at at all - YMMV.)
search for bradybound on the play store, I can't post more than one link..
have you tried this?
Settings - Networks - More - Mobile Networks - Network mode - Select preferred network (2G for example).
Another method i used was mentioned above. Connect via iPhone hot spot.
Hope this helps.
I'm using mitmproxy HTTPS proxy. https://mitmproxy.org/
Mitmproxy is an open source proxy application that allows intercepting HTTP and HTTPS connections between any HTTP(S) client. It allows to monitor, capture and alter these connections in realtime. Change request, response, header, ...
Additionally you can intercept different requests.
e.g. response_delay.py:
from mitmproxy import http
from time import sleep
def response(flow: http.HTTPFlow) -> None:
sleep(5.0)
Then executing this comment delays all responses from the server:
mitmproxy --cert \*.asdf.at=./cert.pem --scripts response_delay.py
In my app I'm using certificate pinning, so you need to add the certificate (private + public)
cat private.key public.key > cert.pem
You can find a simple Tutorial here.
You can find other scripting examples here.
Very old post but I'll add my two cents. I have been VERY happy with this hardware product ( https://apposite-tech.com/products/linktropy-mini/ ) which has enabled us to simulate a lot of real-world conditions. For a long time we had challenges troubleshooting various things that would work in emulator or with airplane mode.
We have several different profiles setup from zero-connectivity to various stages of marginal connectivity, with different degrees of latency, packet loss, and bit-errors. The great thing about it is we can change these on the fly without having to relaunch the app in an emulator. The price has been entirely worth it for our shop, and it's dead simple to use.
I needed to throttle low internet on AndroidTV native device and based on what I have read, the most suitable solution was to limit the internet access directly in my router.
Go to router settings (locally it is smth like 192.168.0.1) -> set up DHCP server (if it's not running) -> choose IP address of a device and set the restriction;
Related
Simulating WiFi device in android emulator with mac80211_hwsim kernel module
I am looking to simulate an additional WiFi device in a rooted android emulator (to simulate a device my company makes). So far I have found the linux kernel module, mac80211_hwsim, which seems like it would help me create virtual networks like this. I believe this is also the mechanism that the emulator uses to create its fake wifi network already. I have found /vendor/bin/mac80211_create_radios which seems to allow me to access that module (to create more channels / radios which appear in ip link show as wlan*). If this is in fact the right way forward, once I create some more channels for that kernel module, I want to be able to connect to a program on my local computer after connected to this other WiFi network (similar to how 10.0.2.2 maps to the host computer). (this looks helpful with the redir command) Does this sound reasonable and does anyone have some tips going forward? It's been challenging to find information that is relevant to Android in this area. Some relevant files for how I believe the emulator does this: /vendor/bin/init.wifi.sh /vendor/bin/init.ranchu-net.sh /vendor/bin/mac80211_create_radios /vendor/etc/simulated_hostapd.conf
Testing Network Throttling using chrome dev-tools for an android app does not work
Goal: Test android app on a physical device with various network connectivity issues (Offline, Slow 3G etc). Android Emulator is not an option for my use case. Steps I have tried: (Remote Debugging) Connect my phone to my computer and open the app on my phone. In chrome "Remote devices" I select my phone and click on inspect for the app opened on my phone. Once the Developer Tools window opens I can play with my app from chrome. In the network tab I can see the throttling options but when I try the offline option or any other option to slow down the network it does not seem to work. The offline/slow 3G option works for a normal website but not when using remote devices. I wanted to see if anyone has tried this option before and if it worked for them and I would appreciate suggestions for better alternatives to test an android app with various network settings other than using chrome remote devices? Other options I have come across are installing a proxy app on PC/Mac and configure networking throttling in the app and then create a wifi hotspot and connect my phone with it. This is possible but it would be tricky with the tools we use so I was looking for a more elegant solution.
The "remote devices" of chrome won't affect your native app. It will not even affect another opened tab other than the one you are "inspecting" and throttling. If you really need to throttle your device's network connection you should use a proxy. A good and easy to handle proxy is Charles web debugging. The free version will cover your needs if you are willing to reconnect every 30 mins. But for sure I recommend you purchase a license since this tool will be always helpful and developers also need to make a living ;) Here is an example of setting up Charles as a proxy for an android device.
It's a little unclear from your question, but I'm assuming that you're using Remote Debugging to run a webpage on an Android device, and you want to profile the webpage from a laptop/desktop connected to the Android. One workaround is to use https://www.webpagetest.org/easy. This actually runs your webpage on a real Motorola G device in Virginia with a Slow 3G connection. It gives you a detailed report on your loading performance, just like the DevTools Performance panel. One of the DevTools team members said that Remote Debugging + Network Throttling should work, but neither of us has tried it recently.
how to run wifi peer to peer application in android emulator..?
I am trying to develop an wifi peer to peer application in android(4.+). The problem here is how to test it. I tried to run that application in android emulator. there was no option to configure wifi in the settings menu, i also tired to enable wifi using the dev tools application form the emulator but it didn't work, And through all my googling over 3 days and i found that Android emulator is not supported the Wifi. So i opted for androidx86 4.0eeepc using virtual box and tired to add devices both wifi and bluetooth (my app uses both bluetooth and wifi) but only bluetooth device got added and it did not work. But my virtual box detected the wifi and bluetooth devices. I just couldnt get them work with the virtual machine. I tried everything like manually adding the addresses using terminal emulator app in androidx86 and used netcfg through the android commandline but neither of them worked. Please suggest and guide me on the correct path to run these kind of applications that use wifi and bluetooth in android. Thanks in advance.
First, be sure you enabled WiFi Direct in the Android settings for the two virtualbox instances: Settings --> Wireless & Networks --> More... --> Wi-Fi direct It has been stated as working once that hurdle was overcome, and I'm sure many have experienced the same...just be sure to enable wifi direct I would have tried exactly what you've already tried by naturally moving from the emulator to the androidx86 project. Although unreliable, I'd recommend looking at and finagling this, if you haven't yet seen it: Android: Simulate WiFi in the emulator? and How to disable/enable network, switch to Wifi in Android emulator? most likely wouldn't have full out success but may be enough to let you know that it works or would work. As far as testing WiFi-Direct/WiFiP2P without you yourself having a device/s, I would recommend: Trying out some of the fiddling as mentioned above. And read through tons of logs. You could always crowd source it to friends, or release an apk on a forum for a small group of testers. Of course, both of those options are not ideal, seamless, or fast. So, I'd definitely hope you get VirtualBox VMs of AndroidX86 4.0 running as it should once you check that setting and pair up the WiFi APs :-)
A near future solution: This might be something to look into in near future. Real devices are hosted by Samsung and screens are streamed to your PC. http://developer.samsung.com/remoteTestLab.do According to an email responded by samsung, which I sent to them earlier. They only have 2 devices (Galaxy Nexus) running on Android v4.0 at the moment. Unfortunately they are not physically close to each other. (One in Korea, One in Poland) But they are planning to upgrade existing Galaxy S2 to v4.0. Because recently Samsung have released v4.0 upgrade for S2. Once they done that, there will be plenty of v4.0 phones. And you can ask them which 2 phones are physically close so you can test Wifi Direct. --------------------------- EDIT --------------------------------- There are plenty of ICS devices there now, which you can test P2P. Check with them which 2 are physically near to each other.
Per the docs: Each instance of the emulator runs behind a virtual router/firewall service that isolates it from your development machine's network interfaces and settings and from the internet. You have to use Network Redirection, as described in the Developer Docs. In essence, you forward specific ports using ADB. Therefore you cannot test certain things like broadcast messages. I have tried doing what you are trying to do, and-- while I won't say it is impossible (anything is possible in computing with enough time, money, and persistence)-- I wasted a lot of time on it. You cannot treat the Android emulator as a normal network peer-to-peer device. As far as I have been able to find, it is a fork of QEMU, and that is just how the QEMU emulator is implemented. QEMU itself does support TUN/TAP bridging, but I was never able to get it working with the Android emulator. If you want to go that route, you may want to investigate running Android in the QEMU emulator, rather than in the SDK's emulator (I see you are already trying a similar approach with VirtualBox). Unfortunately the best way to test a peer-to-peer networking program in Android is with physical devices at this time-- unless your app can suffice with the port forwarding method. See Also: Issue 26:Emulated Androids should be able to communicate via TCP, and Google
(Repeating here my answer elsewhere.) In theory, linux (the kernel underlying android) has mac80211_hwsim driver, which simulates WiFi. It can be used to set up several WiFi devices (an acces point, and another WiFi device, and so on), which would make up a WiFi network. It's useful for testing WiFi programs under linux. Possibly, even under user-mode linux or other isolated virtual "boxes" with linux. In theory, this driver could be used for tests in the android systems where you don't have a real WiFi device (or don't want to use it), and also in some kind of android emulators. Perhaps, one can manage to use this driver in android-x86, or--for testing--in android-x86 run in VirtualBox.
Simulate low network connectivity for Android [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 2 years ago. Improve this question I would like to test my application for cases of low network connectivity. Except standing in the elevator, what is the best way to do this? I've tried wrapping my phone in an aluminum foil, but it didn't help much. I need to test it on a real device, not in an emulator.
This may sound a little crazy, but a microwave oven serves as a microwave shield. Therefore, putting your device inside a microwave oven (DO NOT turn on the microwave oven while your device is inside!) will cause your signal strength to drop significantly. It definitely beats standing inside an elevator...
You can use emulator for this. Take a look at this page: Android Emulator. Pay attention to next two arguments: -netdelay <delay> Set network latency emulation to . Default value is none. See the table in Network Delay Emulation for supported values. -netspeed <speed> Set network speed emulation to . Default value is full. See the table in Network Speed Emulation for supported values. Speeds for reference in increasing kbps: UP DOWN -------- ---------- gsm GSM/CSD 14.4 14.4 hscsd HSCSD 14.4 57.6 gprs GPRS 28.8 57.6 umts UMTS/3G 384.0 384.0 edge EDGE/EGPRS 473.6 473.6 hsdpa HSDPA 5760.0 13,980.0 lte LTE 58,000.0 173,000.0 evdo EVDO 75,000.0 280,000.0 full No limit ∞ ∞
Since iPhones developer option apply on wifi tethering, you can get an iPhone which has iOS 6 and above (and has been set to use for developments with the xcode), set it to emulate the desired network profile, connect your Android device to its hotspot
Update for Android Studio v 1.5 or greater As #LouMorda mentioned in a comment below that the Emulator tab mentioned in original post has been removed in Android Studio v 1.5. Now They've placed these settings in Simulator Settings in AVD Manager. To access these settings: Select Tools -> Android -> AVD Manager Click the Edit AVD button (pencil icon) The Network Settings can be accessed after clicking the Show Advanced Settings button Here is a screenshot of how it may appear: Original Post For anyone using Android Studio IDE: Go to Run -> Edit Configurations Select Android Application -> [Your App] Select Emulator tab Here you can change different values for Network Speed(internet speed) and Network Latency (delay) to simulate different speeds and latencies etc Alternatively, you can enter various arguments in Additional command line options text field as mentioned in #inazaruk's answer. The screenshot below describes how this Run Configuration screen looks like: I know its a bit late to answer to this question, but i hope this helps others facing similar issues! Edit For anyone using eclipse, see #Abhi's answer below.
I know it's an old question but... Some phones nowadays have a setting to utilize 2G only. It's perfect for simulating slow internet on a real device.
Years old but hey, I'll chime in with my foolproof method with Genymotion. Download the Charles free trial: http://www.charlesproxy.com/download/ Install it ClickProxy -> Throttle Settings Set up your HTTP throttled speeds Close that window Click Proxy -> Throttling to enable the throttle Open up a Genymotion emulator Open the wifi settings Long press the enabled wifi connection Click Modify Network Click Show Advanced Options Set Proxy to Manual Set the Proxy hostname to 10.0.3.2 Set the Port to 8888 Click Save And now your network will be throttled!
I have one strategy to settle your problem. You can use the application of proxy to modify or monitor your net status. e.g, Charles. You ought to change the default config of the Charles like the following picture I posted. And finally, you will discover the net status has been shaped into lower pace.
You are also able to test slow internet connectivity on an real android device: Tested with Samsung Galaxy S8 + Android 8.0.0 Go to Settings -> Connection -> Mobile Network -> and under networkmode you can choose to only use 2G or 3G connections
In Android Studio, while running an emulator: 1- Hit settings button at the bottom of the emulator sidebar 2- Go to Cellular 3- Set Network Type
Easy way to test your application with low/bad connection in emulator: Go Run > Run configurations, select your Android Application, and there go to Target tab. Look Emulator launch parameters. Here, you can easy modify Network Speed and Network Latency.
There's a simple way of testing low speeds on a real device that seems to have been overlooked. It does require a Mac and an ethernet (or other wired) network connection. Turn on Wifi sharing on the Mac, turning your computer into a Wifi hotspot, connect your device to this. Use Netlimiter/Charles Proxy or Network Link Conditioner (which you may have already installed) to control the speeds. For more details and to understand what sort of speeds you should test on check out: http://opensignal.com/blog/2016/02/05/go-slow-how-why-to-test-apps-on-poor-connections/
I'm surprised nobody mentioned this. You can tether via Bluetooth, and separate them by ten+ meters(or less with obstacles). You've got a real bad connection. No microwave, no elevator, no software needed.
Or on an actual device you can go to Settings -> Mobile Networks -> Preferred network types and chose the slowest available... Of course this is very limited, but for some test- purposes it might be enough.
Facebook built something called Augmented Traffic Control. A brief summary from their GitHub page: Augmented Traffic Control (ATC) is a tool to simulate network conditions. It allows controlling the connection that a device has to the internet. Developers can use ATC to test their application across varying network conditions, easily emulating high speed, mobile, and even severely impaired networks. Aspects of the connection that can be controlled include: bandwidth latency packet loss corrupted packets packets ordering In order to be able to shape the network traffic, ATC must be running on a device that routes the traffic and sees the real IP address of the device, like your network gateway for instance. This also allows any devices that route through ATC to be able to shape their traffic. Traffic can be shaped/unshaped using a web interface allowing any devices with a web browser to use ATC without the need for a client application. You can find it here on GitHub: https://github.com/facebook/augmented-traffic-control They have also written a blog post about it: https://code.facebook.com/posts/1561127100804165/augmented-traffic-control-a-tool-to-simulate-network-conditions/
UPDATE on the Android studio AVD: open AVD manager create/edit AVD click advanced settings select your preferred connectivity setting No microwaves or elevators :)
for and mac OS user you can use Network Link Conditioner which could be downloaded from apple. set it as a AP on mac and any divices could connected it. you can either use facebook open source tools ATC http://facebook.github.io/augmented-traffic-control/
Go Run > Run configurations, select your Android Application, and there go to Target tab. Do changes as shown in the figure.
I was struggling with this problem for half a day, finally I came to this solution: Testing on a real device doesn't make much sense overall as you have to go through a lot to make it work. The only logical way to achieve real testing is to make your phone connect to a low quality cellular network, like EDGE, if your phone company provides it. You can try to do this by dialing *#*#4636#*#* in the phone app The original Android emulator is way too slow for testing and doesn't achieve more than the solution above. The best way to do this is using Genymotion. It's an Android emulator with much better performance than the original AVDs and the version for personal use is free. After you created your virtual device in Genymotion, just go through this tutorial to set a proxy for the device. Run a proxy server on your host machine that simulates bad network conditions, like Crapify or Toxiproxy (I only tested the former) and you're good to go. Update: I just realized you can pick the very same strategy with real devices too. I feel like an idiot for not realizing it sooner. Just start a Crapify proxy on your computer, set your phone proxy to your computer's local address and voila, you've got crappy internet on your phone.
Do you want to test for no network connection, or just a slow network connection? If the former, you can go to Settings > Wireless & networks > Airplane mode and turn Airplane mode on. That will let you test network unavailability on an actual device.
as suggested by #VicVu Charles (or any other proxy tool) is an easier way to go. But I would Like to add that you can do this with your device also, not just genymotion or other emulators. Process will be the same: Modify your device/emulator's wifi setting to use manual proxy. And then Set the Proxy hostname & port a. set the hostname as ip of your system (get the ip of your pc/mac using ifconfig/ifconfig) b. set the port number of genymotion (check the proxy settings in charles) PS: Your device/emulator MUST be using the same wifi since the ip you are using will most probably be the private ip.
Open terminal inAndroid Studio and Go to ../../Android/sdk/tools. 'emulator' executable should be available here. Run ./emulator -netdelay "delay_in_millis" -avd "emulator_device_name" Ex: ./emulator -netdelay 60000 -avd Nexus_5_API_21 Now build your app and install it in emulator. Run your scenario in app. Make sure you have your code changes in app that sets timeout to your request and handles that.
Just go to Android device monitor from Android studio , then DDMS -> Emulator Control.There will be Speed and Latency properties.
I found netlimiter4 to be the best solution for throttling data to emulators. It provides for granular control through a decent gui and gives you graphical feedback on the data throughput to each process. Currently in a free beta. screenshot http://www.netlimiter.com/products/nl4 There are apps available on the play store to throttle to actual devices but they require root(I cant provide any advice as to how well they work, if at at all - YMMV.) search for bradybound on the play store, I can't post more than one link..
have you tried this? Settings - Networks - More - Mobile Networks - Network mode - Select preferred network (2G for example). Another method i used was mentioned above. Connect via iPhone hot spot. Hope this helps.
I'm using mitmproxy HTTPS proxy. https://mitmproxy.org/ Mitmproxy is an open source proxy application that allows intercepting HTTP and HTTPS connections between any HTTP(S) client. It allows to monitor, capture and alter these connections in realtime. Change request, response, header, ... Additionally you can intercept different requests. e.g. response_delay.py: from mitmproxy import http from time import sleep def response(flow: http.HTTPFlow) -> None: sleep(5.0) Then executing this comment delays all responses from the server: mitmproxy --cert \*.asdf.at=./cert.pem --scripts response_delay.py In my app I'm using certificate pinning, so you need to add the certificate (private + public) cat private.key public.key > cert.pem You can find a simple Tutorial here. You can find other scripting examples here.
Very old post but I'll add my two cents. I have been VERY happy with this hardware product ( https://apposite-tech.com/products/linktropy-mini/ ) which has enabled us to simulate a lot of real-world conditions. For a long time we had challenges troubleshooting various things that would work in emulator or with airplane mode. We have several different profiles setup from zero-connectivity to various stages of marginal connectivity, with different degrees of latency, packet loss, and bit-errors. The great thing about it is we can change these on the fly without having to relaunch the app in an emulator. The price has been entirely worth it for our shop, and it's dead simple to use.
I needed to throttle low internet on AndroidTV native device and based on what I have read, the most suitable solution was to limit the internet access directly in my router. Go to router settings (locally it is smth like 192.168.0.1) -> set up DHCP server (if it's not running) -> choose IP address of a device and set the restriction;
How to set up an ad hoc network by using the shell on a rooted Android device?
In the moment I am working with some ad hoc routing protocols (namely OLSR and B.A.T.M.A.N.) on rooted Android devices running Cyanogenmod. My tests are working pretty well. However, there is one thing which really is annoying: I can only connect to an existing ad hoc network, but not create one manually using only the phones. Right now I am using my laptop to set up an ad hoc network and to run a small DHCP server. Do you know how to create an ad hoc network manually by using the shell on Android? I have found some methods how this should work, but none did work for me. I tried using ifconfig, iwconfig, netcfg and even wpa_cli (which seemed to be the best choice for this). But after any try the system fell back into "no wifi connected" state - even if the phone stayed in ad hoc mode for a couple of seconds while searching for an IP. I will be so gladful if I can finally get around this problem because then I might actually use my laptop for Internet access (and therefore searching for online help during the tests) instead of using it to set up an ad hoc network. :-)
I'm not really clear on the technical details, but android-wifi-tether requires you to have a custom kernel with NETFILTER support, which I don't know if Cyanogenmod has. You might try using another open source project as an example: Barnacle Tether. It doesn't require a custom kernel. I've started looking at the source for Barnacle for my own project. It's pretty easy to compile, but I've only just begun playing with it so I don't know the exact answer to your question.
Correct me if I'm wrong, but didn't the old cyanogen tethering app (android 1.6, before tethering was officially offered) create an ad-hoc network for the tether clients? (I ended up using it not to tether, but just to set up a network so I could ssh into the phone from a laptop while I was playing around with USB host drivers and so couldn't use ADB.)