App traffic test--using the TCP send and receive length statistics feature provided by Android itself

Source: Internet
Author: User

There are 3 places in the Linux system to save the traffic statistics files, for Android system also applies:

(1) Under/proc/net/dev, you can view the incoming and outgoing traffic of each network interface (equivalent to adb shell Cat/proc/pid/net/dev,adbshell cat/sys/class/net/wlan0/statistics/rx _bytes)

(2) Under/sys/class/net/, you can find a directory of related categories, such as wlan0. Statistics downstream rxbytes and Txbytes records in their subdirectories

(3) In/PROC/UID_STAT/{UID}/TCP_RCV record the UID application download traffic byte,/PROC/UID_STAT/{UID}/TCP_SND has the Uid app upload traffic bytes

The traffic similarities and differences between the 5 local statistics are as follows:

Recommended Use order: D > E > C > A> B

Recommended D and E (other methods you can practice according to the ADB command of the prompt)

Note: android4.0 above can use/proc/uid_stat/$uid/TCP_RCV and/proc/uid_stat/$uid/tcp_snd to get up and down traffic for a program, while the following versions of 4.0 use cat/proc/$ Pid/net/dev to view the traffic on the upper and lower lines. The relationship between UID and PID can be obtained from/data/system/packages.list this file, but/proc/uid_stat/$uid this way, some vendors in the Android 6.0 system may have made some modifications, The Uid_stat folder is not displayed in the proc directory.

Calculation of the flow rate during the measured time

Send traffic: tcp_snd_new-tcp_snd_old=2032150-893233=1128917bytes

Incoming traffic: tcp_rcv_new-tcp_rcv_old=18648825-1350829=17297996bytes

App traffic test--using the TCP send and receive length statistics feature provided by Android itself

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.