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

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


当前回答

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/

其他回答

有一种在真实设备上测试低速的简单方法似乎被忽视了。它确实需要一台Mac电脑和以太网(或其他有线)网络连接。

在Mac上打开Wifi共享,把你的电脑变成Wifi热点,把你的设备连接到这个。使用Netlimiter/Charles Proxy或Network Link Conditioner(您可能已经安装了)来控制速度。

欲了解更多详细信息,并了解您应该在签出时测试什么样的速度:http://opensignal.com/blog/2016/02/05/go-slow-how-why-to-test-apps-on-poor-connections/

我很惊讶没人提到这一点。你可以通过蓝牙连接,并将它们分开十多米(或更少的障碍物)。你的信号很差。没有微波炉,没有电梯,不需要软件。

你可以使用模拟器。看看这个页面: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 ∞ ∞

这听起来可能有点疯狂,但微波炉是作为微波屏蔽的。因此,把你的设备放在微波炉里(当你的设备在里面的时候不要打开微波炉!)会导致你的信号强度显著下降。这绝对比站在电梯里强……

正如@VicVu Charles(或任何其他代理工具)所建议的那样,是一种更简单的方法。但我想补充的是,你也可以在你的设备上做到这一点,而不仅仅是genymotion或其他模拟器。过程是一样的:

修改您的设备/模拟器的wifi设置以使用手动代理。然后设置代理主机名和端口 A.将主机名设置为您系统的IP(使用ifconfig/ifconfig获取您pc/mac的IP) B.设置genymotion端口号(查看charles中的proxy Settings)

PS:你的设备/模拟器必须使用相同的wifi,因为你正在使用的ip很可能是私有ip。