Simulate Slow Internet Connection on a REAL device? [duplicate]

送分小仙女□ 提交于 2019-12-21 03:53:25

问题


I need to test my application in conditions where even 2G Internet connectivity isn't at its full coverage (i.e. 2 bars instead of 4, 2G).

I prefer conducting these tests over WiFi.

Is there a way (programmatically or otherwise) to tell the Android OS on the real device to slow down or throttle Internet connection 56 Kbit/s?

Note: I know how to do this on the emulator. I'm looking for a way to do this on a real device.

Is this possible?


回答1:


In one of your comments you mentioned that you have a DD-WRT router, which is really a tiny Linux box. So you may be able to get a way with the tc command:

tc qdisc add dev $DEV root handle 1: cbq avpkt 1000 bandwidth 10mbit 
tc class add dev $DEV parent 1: classid 1:1 cbq rate 512kbit allot 1500 prio 5 bounded isolated 
tc filter add dev $DEV parent 1: protocol ip prio 16 u32 match ip dst 195.96.96.97 flowid 1:1



回答2:


It kind of depends on what you have on the upstream side. If you're transmitting some kind of test load, write a driver at the upstream end that does, in fact, slow itself down -- although sleep() is a bad choice. What you'll be writing is essentially a fairly hard real-time program if you hope to get anything resembling a real workload.

(When I say "a driver" btw , I don't mean necessarily a device driver, just some kind of driver program.)

But are you really trying to simulate a slow connection, or a degraded and noisy connection that has a low effective data rate?



来源:https://stackoverflow.com/questions/11488888/simulate-slow-internet-connection-on-a-real-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!