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