我想测试我的应用程序的低网络连接的情况。除了站在电梯里,还有什么最好的方法呢?我试过用铝箔纸包我的手机,但没有用。

我需要在真正的设备上测试它,而不是在模拟器上。


当前回答

Facebook建立了一个叫做增强交通控制的东西。GitHub页面上的简要总结:

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.

你可以在GitHub上找到它:https://github.com/facebook/augmented-traffic-control

他们还为此写了一篇博客:https://code.facebook.com/posts/1561127100804165/augmented-traffic-control-a-tool-to-simulate-network-conditions/

其他回答

运行>运行配置,选择Android应用程序,然后进入目标选项卡。按照图中所示进行更改。

几岁了,但是嘿,我会用Genymotion来配合我的万无一失的方法。

下载Charles免费试用版:http://www.charlesproxy.com/download/ 安装它 ClickProxy ->节流阀设置 设置HTTP节流速度 关闭窗口 单击“Proxy -> Throttling”,开启节流阀 打开Genymotion模拟器 打开wifi设置 长按开启的wifi连接 单击“修改网络” 单击“显示高级选项” 设置代理为手动 设置Proxy主机名为10.0.3.2 端口设置为“8888” 点击保存

现在你的网络将被阻塞!

我需要在AndroidTV本机设备上限制低网络,根据我所读到的,最合适的解决方案是直接在我的路由器上限制互联网访问。 进入路由器设置(本地是smth,如192.168.0.1)->设置DHCP服务器(如果没有运行)->选择设备的IP地址并设置限制;

我为这个问题纠结了半天,终于想出了这个解决方案:

在真正的设备上进行测试并没有太大意义,因为你必须经历很多事情才能让它正常工作。实现真正测试的唯一合理方法是让你的手机连接到低质量的蜂窝网络,比如EDGE,如果你的电话公司提供这种网络的话。你可以试着在手机应用程序中拨打*#*#4636#*#* 最初的Android模拟器对于测试来说太慢了,并且不能实现比上面的解决方案更多的功能。

最好的方法就是使用Genymotion。这是一个Android模拟器,性能比原来的avd要好得多,个人使用的版本是免费的。

在Genymotion中创建虚拟设备后,只需通过本教程为设备设置代理。

在您的主机上运行一个模拟恶劣网络条件的代理服务器,如Crapify或Toxiproxy(我只测试了前者),这样就可以了。

更新:

我刚刚意识到,你也可以在真实的设备上选择同样的策略。我觉得自己像个白痴,没有早点意识到这一点。只要在你的电脑上启动一个Crapify代理,将你的手机代理设置为你电脑的本地地址,瞧,你的手机上就有了蹩脚的互联网。

对于mac操作系统用户,你可以使用网络链接调节器,可以从苹果下载。将其设置为mac上的AP,任何设备都可以连接它。

你可以使用facebook的开源工具ATC http://facebook.github.io/augmented-traffic-control/