5

I have a quick question on Android's netstats and how they are reported.

by running this code in cmd: adb shell cat proc/net/xt_qtaguid/stats > C:\netstats.txt"

I get a file that looks more or less like this (I took snippets for sake of questions):

idx iface acct_tag_hex uid_tag_int cnt_set rx_bytes rx_packets tx_bytes tx_packets rx_tcp_bytes rx_tcp_packets rx_udp_bytes rx_udp_packets rx_other_bytes rx_other_packets tx_tcp_bytes tx_tcp_packets tx_udp_bytes tx_udp_packets tx_other_bytes tx_other_packets  
44 wlan0 0x0 10123 0 45148 186 32150 265 45148 186 0 0 0 0 32150 265 0 0 0 0
45 wlan0 0x0 10123 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
46 wlan0 0x0 10138 0 19775 84 13625 129 19775 84 0 0 0 0 13625 129 0 0 0 0
47 wlan0 0x0 10138 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
48 wlan0 0x0 10142 0 36422 67 43115 105 36070 64 352 3 0 0 42467 96 648 9 0 0
49 wlan0 0x0 10142 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50 wlan0 0x300000000 10123 0 7765 35 4820 44 7765 35 0 0 0 0 4820 44 0 0 0 0
51 wlan0 0x300000000 10123 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
52 wlan0 0x3f500000000 10096 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
53 wlan0 0x3f500000000 10096 1 2937868 2025 32034 747 2937868 2025 0 0 0 0 32034 747 0 0 0 
54 wlan0 0xdc4e7700000000 10022 0 31623 75 18611 106 31623 75 0 0 0 0 18611 106 0 0 0 0
55 wlan0 0xdc4e7700000000 10022 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
56 wlan0 0x1000000100000000 10123 0 21864 116 18225 145 21864 116 0 0 0 0 18225 145 0 0 0 0
57 wlan0 0x1000000100000000 10123 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
61 wlan0 0x1010000000000000 10045 1 33010 109 27695 113 33010 109 0 0 0 0 27695 113 0 0 0 0
62 wlan0 0x1100000000000000 10046 0 6804 14 2064 19 6804 14 0 0 0 0 2064 19 0 0 0 0
63 wlan0 0x1100000000000000 10046 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
64 wlan0 0x1144000400000000 10022 0 2532 5 1860 6 2532 5 0 0 0 0 1860 6 0 0 0 0
65 wlan0 0x1144000400000000 10022 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
66 wlan0 0x1244000400000000 10022 0 8197 14 3134 20 8197 14 0 0 0 0 3134 20 0 0 0 0
67 wlan0 0x1244000400000000 10022 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
68 wlan0 0xffffff0100000000 10045 0 8566814 6535 159315 2688 8566814 6535 0 0 0 0 159315 2688 0 0 0 0
69 wlan0 0xffffff0100000000 10045 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

I know that it is broken down by UID's (10123,10138,10142,etc.) but what I cant figure out is what the cnt_set is (why each UID is broken up into either 0 or 1) and what acct_tag_hex is (my only guess is that it means a different thread or socket)?

If anyone could give me some basic insight on what those two things mean, I would greatly appreciate it.

Thanks -Z

Vikalp Patel
  • 10,669
  • 6
  • 61
  • 96
Nefariis
  • 3,451
  • 10
  • 34
  • 52

1 Answers1

13

acct_tag_hex is a socket tag

Lines with cnt_set==0 are for background data

Lines with cnt_set==1 are for foreground data

Total traffic is a sum of both

Alex P.
  • 30,437
  • 17
  • 118
  • 169
  • Why is there data records on a few of the cnt_set=1 and not in the cnt_set=0 for the same UID. For example:
    12 wlan0 0x0 10008 0 0 0 52 1 0 0 0 0 0 0 52 1 0 0 0 0
    13 wlan0 0x0 10008 1 25425 30 3073 39 25425 30 0 0 0 0 3073 39 0 0 0 0

    In this example, since Im ignoring the cnt=1 does that mean this application uses no data?
    – Nefariis Mar 01 '13 at 22:15
  • It is just to distinguish 2 different sets of data. Whoever is calling the com.android.server.NetworkManagementSocketTagger.setKernelCounterSet to switch the counter set should have some purpose for doing so. The total traffic would be the sum of the two. – Alex P. Mar 01 '13 at 22:29
  • So it is possible to show the data on the cnt=1? would it then be better to add the data from both 0 and 1 together to get a more accurate result of data traffic across the entire UID? If you look at the example from the original question, line 52 and 53, it seems like in that case I would have to use cnt=1, and though I didnt show it I have a few apps that have data posted on both 0 & 1. – Nefariis Mar 01 '13 at 22:34
  • my original answer from generic linux kernel perspective. I have checked the android source code and updated the answer with android specifics. – Alex P. Mar 01 '13 at 23:26