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

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


当前回答

由于iPhone开发者选项适用于wifi绑定,你可以获得一部iOS 6及以上版本的iPhone(并已被设置为使用xcode开发),将其设置为模拟所需的网络配置文件,将你的Android设备连接到它的热点

其他回答

我发现netlimiter4是将数据节流到模拟器的最佳解决方案。 它通过体面的gui提供粒度控制,并为每个进程的数据吞吐量提供图形化反馈。目前处于免费测试版。 截图

http://www.netlimiter.com/products/nl4

在游戏商店中有一些应用程序可以节流到实际设备上,但它们需要root(我不能提供任何关于它们工作得如何的建议,如果在所有- YMMV)。

在游戏商店搜索bradybound,我不能发布超过一个链接。

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

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

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

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

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

更新:

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

非常老的帖子,但我将补充我的意见。我对这个硬件产品(https://apposite-tech.com/products/linktropy-mini/)非常满意,它使我们能够模拟许多现实世界的条件。在很长一段时间里,我们都面临着解决各种问题的挑战,这些问题将在模拟器或飞行模式下工作。

我们设置了几个不同的配置文件,从零连接到边缘连接的各个阶段,具有不同程度的延迟、数据包丢失和误码。这样做的好处是我们可以在运行中更改这些,而不必在模拟器中重新启动应用程序。对于我们的商店来说,这个价格是完全值得的,而且使用起来非常简单。

你可以使用模拟器。看看这个页面:Android模拟器。请注意下面两个论点:

-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 ∞ ∞

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/