Andorid traffic Test Method

Source: Internet
Author: User

In the context of the mobile Internet, traffic testing is a very necessary Terminal Test in the Age of waste of money. Lisa recently used the blank time to conduct research on Android traffic testing. There are many methods to do this, and the methods are constantly updated. For example, andorid4.0 comes with a "traffic usage ", some tools also carry the traffic statistics function, but Lisa seems unreliable after trying it out.The most reliable methodThere are two methods:

[213 youth method] a combination of tcpdump and Wireshark

[Method for normal youth] reads the value of the tcp_snd/tcp_svn file corresponding to the app.

Of course, there is also a better and more labor-saving method. In YY, let's call it the Bai fumei method:

[Bai fumei method] Make the above two methods into tools ...... (To be continued, share it with you)

What does traffic testing bring to us?

1.We can clearly know how much traffic a user needs to use our products in a certain scenario.

2.Traffic data analysis guides us through optimization.

For example, is CGI call and parameter settings reasonable, and can some resources or configurations be localized?

3.Traffic optimization can optimize the speed.

Reducing the number of TCP packets or directly reducing the number of requests can lead to speed optimization.

In general, one point is to help users save traffic money!!!

[Method 1: 213 youth method] tcpdump + Wireshark Method

Step 1: TCPDUMP packet capture

1.ADB and Java environments and Wireshark are installed by default.

2.Download tcpdump: http://www.strazzere.com/android/tcpdump

3.Open cmd, enter the ADB directory, and test the device connection.

 

4.Copy the/data/local/tcpdump directory of tcpdump (this step requires the root permission of the mobile phone)

 

Now we can see the root flag #, indicating that the current status is root.

Use ADB shell to create the directory/data/local/tcpdumpb on your mobile phone and execute the following command:

D: \ adbtools is the location where I downloaded tcpdump.

5.Modify tcpdump Permissions

6.Run the packet capture command

ADB shell data/local/tcpdump-p-VV-S 0-W/sdcard/capture. pcap

7.Export the captured package in the sdcard directory (ADB pull/sdcard/capture. pcap)

Step 2: Wireshark collects traffic

Wireshark opens the packet capture file and uses filte for filtering. According to Wireshark's filter syntax, suppose the address of the target server corresponding to the app is (121.14.76.22)

 

Filter Syntax:

"Inbound traffic" ip. src = 121.14.76.22

"Outbound traffic" ip. dst = 121.14.76.22

How can we count the size of these filtered packages? There is a summary under statistics

The data we want is here.

The incoming traffic data we want is the value in the red box.

 [Method 2] view the tcp_rcv and tcp_snd files under/proc/uid_stat/<uid> /.

1.What is uid?

After the ADB shell enters the mobile phone, execute PS

 

The UID value is 63 + 10000 = 10063, that is, 10000 is added to the data after the app to be counted.

2.Cat. The unit is byte.

 

Lisa collects the results of these two methods in the same scenario, with a small difference.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.