Weak net testing with Charles

The current APP network environment is relatively complex. The network standards include 2G, 3G, 4G networks, and more and more public Wi-Fi. Different network environments and network standards will have a certain impact on the use of apps by users. In addition, the current app usage scenarios are changing, such as entering the subway, getting on the bus, entering the elevator, etc., which makes the weak network test particularly important. If the app does not handle various network anomalies compliantly, users may encounter problems such as app crash, ANR, and data loss in daily life. Therefore, app network testing, especially weak network testing, is particularly important. This article sorts out the main points of app network testing and the common simulation methods for weak network testing, so that everyone can have a comprehensive understanding of network testing.

APP network test points

1. Functional test under each network

  • Under different networks, check the basic function points
  • Operator Mobile, Unicom, Telecom access point test (requires the use of an actual SIM card)
  • If there is a smart DNS function, you also need to pay attention to the operator's judgment/classification
  • High latency, high packet loss, no network, and fake hotspots can also be classified as weak network tests

2. Network switching test
Some APPs have intelligent DNS function, and network switching involves DNS switching.
Network switching detection mechanism: Android can monitor system broadcasts
3. Weak network testing
User experience and exception handling are all network scenarios that need to be paid attention to, but in weak network scenarios, it needs to be focused.

Weak network test simulation

What kind of network is a weak network

When the rate is lower than 2G, it is a weak network, and 3G can also be classified as a weak network. Generally, Wi-Fi is not included in the weak network test.

How to perform a weak net test

1. Network switching of SIM card
Mobile phone - settings - mobile network settings - network type to select
3G, 4G card can be set to turn off 3G/4G, only use 2G network.
2. Specific weak network scenario test, common scenarios include: subway/bus, elevator, stairwell, parking lot
3. Use virtual machine to simulate network speed, such as a weak network tester built with Raspberry Pi
4. Use software for network proxy , simulate different network bandwidth, delay rate, packet loss rate

Common tools for weak network simulation

Method 1: Charles Weak Network Simulation

Analysis of

configuration parameters:
bandwidth - bandwidth, that is, uplink and downlink data transmission speed
utilisation - bandwidth availability, most modern is 100%
round-trip latency - the delay of the first request, the unit is ms.
MTU - the maximum transmission unit, that is, the maximum size of the TCP packet, which can more realistically simulate the TCP layer, the packetization of each transmission.
Releability - refers to the reliability of the connection. This refers to the reliability rate of 10kb. Used to simulate network instability.
Stability - connection stability, also affects bandwidth availability. Used to simulate mobile networks, where mobile network connections are generally unreliable.

Reference for specific network settings:

Fiddler can also simulate a weak network environment, please refer to: Fiddler Weak Network Simulation

Method 2: Weak network simulation of chrome's webview debugging tool

The disadvantage of using chrome's webview debugging tool is that it is only suitable for weak network simulation of web pages.
Specific steps:
(1) The application enables the webview debugging function, as follows:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    WebView.setWebContentsDebuggingEnabled(true);
}
(2) Connect the mobile phone to the computer, run the APP, and enter The specific H5 page;
(3) Open the Webview in the DevTools of chrome: enter chrome://inspect/#devices, the connected device will be displayed, select the inspect
network page of the webview to be debugged, and the No throttling drop-down box can perform network simulation.

Method 3: iOS mobile phone comes with Network Link Conditioner weak network simulation

Open the developer options on the iPhone. For details, refer to
Settings - Developer Options > Network Link Conditioner entry.
The system has built-in common network configurations, and custom configurations can also be added.
Specific configuration parameters:
in Bandwidth downlink bandwidth, that is, downlink network speed.
In packet loss downlink packet loss rate
in delay downlink delay, in ms
out bandwidth uplink bandwidth
out packet loss uplink packet loss rate
out delay uplink delay
DNS delay DNS resolution delay
protocol Supports Any , IPV4, IPV6
interface supports Any, WI-Fi, cellular (cellular network)
specific steps refer to:
 

Network test classic problem sharing

Scenario 1: Under the weak network, the program crashes during the page loading process.
Cause: The webview timeout processing is not on the UI thread. Operations such as toast and closing pages need to be done on the UI thread.

Scenario 2: 302 jumps to the page, after reaching the built-in timeout threshold, the webview automatically closes.
Reason: The business has the logic to automatically close the page load timeout, and the timeout mechanism does not consider the 302 scenario.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324762988&siteId=291194637