Android dumpsys 使用之分析网络使用情况

版权声明:转载请注明出处,作者:https://me.csdn.net/O_O___O_O https://blog.csdn.net/O_O___O_O/article/details/52853049

1. netstats

netstats 是 Android 提供的一个分析网络使用情况的工具,可以提供启动以来的网络使用率的统计数据。

2. 输入

需要查看网络的统计信息,使用以下命令:

adb shell dumpsys netstats

又一个没有使用说明的命令

3. 输出

输出的具体信息,根据 android 版本的不同而有所差异,主要包含以下几类信息:

  • Active interfaces
  • Active UID interfaces
  • Dev statistics
  • Xt statistics
  • UID statistics (sometimes also called “Detailed UID statistics”)
  • UID tag statistics

Active interfaces/Active UID interfaces

一下为一个输出示例

Active interfaces:
  iface=tun0 ident=[{type=VPN, subType=COMBINED}] 
  iface=wlan0 ident=[{type=WIFI, subType=COMBINED, networkId="DEZNG"}] 
Active UID interfaces:
  iface=tun0 ident=[{type=VPN, subType=COMBINED}] 
  iface=wlan0 ident=[{type=WIFI, subType=COMBINED, networkId="DEZNG"}] 

官方文档中介绍说,大多情况下这两个是一样的,但是我不知道这两个的含义是什么。

Dev statistics/Xt statistics

Dev stats:
  Pending bytes: 0
  History since boot:
  ident=[{type=MOBILE, subType=COMBINED, subscriberId=460019...}] uid=-1 set=ALL tag=0x0
    NetworkStatsHistory: bucketDuration=3600
      st=1476554400 rb=147 rp=2 tb=625 tp=10 op=0
      st=1476558000 rb=9119065 rp=10234 tb=1122379 tp=14534 op=0
      st=1476561600 rb=685 rp=7 tb=5988 tp=87 op=0
      st=1476565200 rb=56866 rp=434 tb=93548 tp=974 op=0
      st=1476568800 rb=32451 rp=240 tb=48348 tp=575 op=0
      st=1476572400 rb=232625 rp=664 tb=112444 tp=1397 op=0
      st=1476576000 rb=78499 rp=473 tb=82412 tp=949 op=0
      st=1476579600 rb=380604 rp=873 tb=125371 tp=1462 op=0
      st=1476583200 rb=1523598 rp=1366 tb=93139 tp=1199 op=0
      st=1476586800 rb=472665 rp=1697 tb=264310 tp=2834 op=0
      st=1476590400 rb=351541 rp=1148 tb=176249 tp=1924 op=0
      st=1476594000 rb=298094 rp=1135 tb=187128 tp=1867 op=0
      st=1476597600 rb=194756 rp=489 tb=74575 tp=798 op=0
      st=1476601200 rb=23894839 rp=22527 tb=1622476 tp=17368 op=0
      st=1476612000 rb=304563 rp=1094 tb=174651 tp=1661 op=0
      st=1476615600 rb=3688120 rp=7360 tb=1241349 tp=11636 op=0
      st=1476626400 rb=1215522 rp=2959 tb=635717 tp=4963 op=0
      st=1476630000 rb=2402744 rp=5398 tb=1015727 tp=7560 op=0
      st=1476644400 rb=9205777 rp=7713 tb=559336 tp=8260 op=0
      st=1476648000 rb=583 rp=7 tb=3205 tp=47 op=0
      st=1476651600 rb=47179 rp=266 tb=49427 tp=547 op=0
      st=1476655200 rb=76986 rp=436 tb=83705 tp=887 op=0
      st=1476658800 rb=102438 rp=450 tb=123020 tp=712 op=0
      st=1476662400 rb=295328 rp=803 tb=128119 tp=1526 op=0
      st=1476666000 rb=5485026 rp=9896 tb=2306372 tp=12211 op=0
      st=1476669600 rb=194 rp=2 tb=484 tp=7 op=0
      st=1476673200 rb=1054728 rp=1853 tb=402514 tp=2711 op=0
      st=1476676800 rb=740978 rp=1466 tb=216874 tp=2026 op=0
      st=1476680400 rb=640 rp=6 tb=2216 tp=32 op=0
      st=1476687600 rb=14694 rp=98 tb=17508 tp=173 op=0
      st=1476698400 rb=19047965 rp=20508 tb=2555068 tp=24952 op=0
      st=1476705600 rb=525308 rp=1324 tb=251311 tp=2152 op=0
      st=1476709200 rb=5295132 rp=10747 tb=2318397 tp=15371 op=0
      st=1476716400 rb=388 rp=4 tb=2000 tp=29 op=0
      st=1476734400 rb=41748 rp=268 tb=47340 tp=533 op=0
      st=1476738000 rb=95071 rp=430 tb=75082 tp=855 op=0
      st=1476741600 rb=115255 rp=653 tb=115152 tp=1160 op=0
      st=1476745200 rb=25003 rp=254 tb=36810 tp=550 op=0
      st=1476748800 rb=54536 rp=287 tb=51265 tp=508 op=0
      st=1476752400 rb=14269989 rp=13913 tb=1005255 tp=12436 op=0
      st=1476759600 rb=344520 rp=742 tb=116208 tp=1177 op=0
      st=1476763200 rb=1163190 rp=1279 tb=237168 tp=1396 op=0
      st=1476777600 rb=88796 rp=320 tb=50704 tp=560 op=0
      st=1476784800 rb=76247322 rp=73626 tb=4343016 tp=55443 op=0
  ident=[{type=WIFI, subType=COMBINED, networkId="DDDDD"}] uid=-1 set=ALL tag=0x0
    NetworkStatsHistory: bucketDuration=3600
      st=1476554400 rb=1524758 rp=1216 tb=95079 tp=968 op=0
      st=1476558000 rb=58685410 rp=46680 tb=3372042 tp=35066 op=0
      st=1476561600 rb=332231 rp=1373 tb=295474 tp=1938 op=0
      st=1476565200 rb=333056 rp=1686 tb=295348 tp=2476 op=0
      st=1476568800 rb=248179 rp=1270 tb=247145 tp=1820 op=0
      st=1476572400 rb=428260 rp=1946 tb=406182 tp=2709 op=0
      st=1476576000 rb=616724 rp=1843 tb=295023 tp=2593 op=0
      st=1476579600 rb=573984 rp=1502 tb=235383 tp=2173 op=0
      st=1476583200 rb=507405 rp=1584 tb=237332 tp=2244 op=0
      st=1476586800 rb=232239 rp=723 tb=119885 tp=1118 op=0
      st=1476590400 rb=276189 rp=887 tb=162506 tp=1264 op=0
      st=1476594000 rb=962706 rp=1596 tb=219755 tp=2162 op=0
      st=1476597600 rb=16811890 rp=16444 tb=1409221 tp=14058 op=0
      st=1476601200 rb=230042 rp=670 tb=114503 tp=1018 op=0
      st=1476630000 rb=5138582 rp=6283 tb=875742 tp=6951 op=0
      st=1476633600 rb=6523473 rp=7910 tb=1009279 tp=8966 op=0
      st=1476637200 rb=184700 rp=708 tb=93127 tp=822 op=0
      st=1476640800 rb=59135352 rp=44377 tb=2143416 tp=30194 op=0
      st=1476644400 rb=212273036 rp=152337 tb=6650334 tp=94332 op=0
      st=1476648000 rb=321485 rp=1562 tb=290745 tp=2290 op=0
      st=1476651600 rb=198580 rp=954 tb=177693 tp=1460 op=0
      st=1476655200 rb=185225 rp=817 tb=153815 tp=1186 op=0
      st=1476658800 rb=267227 rp=1094 tb=177651 tp=1654 op=0
      st=1476662400 rb=545149 rp=1951 tb=318380 tp=2770 op=0
      st=1476666000 rb=131104358 rp=93902 tb=3860007 tp=63008 op=0
      st=1476709200 rb=15958316 rp=15494 tb=1730925 tp=16144 op=0
      st=1476712800 rb=26735696 rp=20406 tb=1325484 tp=17722 op=0
      st=1476716400 rb=30779605 rp=25307 tb=2004075 tp=24126 op=0
      st=1476720000 rb=9956469 rp=10390 tb=1209633 tp=10393 op=0
      st=1476723600 rb=59814801 rp=48710 tb=4177689 tp=43184 op=0
      st=1476727200 rb=8769991 rp=8078 tb=621426 tp=6513 op=0
      st=1476730800 rb=230924 rp=1108 tb=210527 tp=1510 op=0
      st=1476734400 rb=258729 rp=1156 tb=191221 tp=1592 op=0
      st=1476738000 rb=201413 rp=1056 tb=186083 tp=1541 op=0
      st=1476741600 rb=98970 rp=607 tb=112975 tp=916 op=0
      st=1476745200 rb=491309 rp=1810 tb=362495 tp=2670 op=0
      st=1476748800 rb=8529305 rp=7644 tb=541748 tp=6330 op=0
      st=1476752400 rb=2247 rp=22 tb=3886 tp=52 op=0
  ident=[{type=WIFI, subType=COMBINED, networkId="DEZNG"}] uid=-1 set=ALL tag=0x0
    NetworkStatsHistory: bucketDuration=3600
      st=1476601200 rb=279029 rp=1394 tb=226345 tp=1958 op=0
      st=1476604800 rb=715839 rp=1726 tb=192464 tp=1655 op=0
      st=1476608400 rb=1135634 rp=2084 tb=182302 tp=1888 op=0
      st=1476612000 rb=1951934 rp=4182 tb=595289 tp=4722 op=0
      st=1476615600 rb=67686 rp=363 tb=67928 tp=485 op=0
      st=1476619200 rb=947670 rp=1757 tb=218210 tp=1966 op=0
      st=1476622800 rb=12274517 rp=12188 tb=1000794 tp=8992 op=0
      st=1476626400 rb=992461 rp=2608 tb=341375 tp=3164 op=0
      st=1476666000 rb=619353 rp=1855 tb=387073 tp=2207 op=0
      st=1476669600 rb=2081784 rp=4039 tb=547203 tp=4682 op=0
      st=1476673200 rb=17682576 rp=16705 tb=1816953 tp=14185 op=0
      st=1476676800 rb=3992907 rp=6717 tb=929248 tp=7308 op=0
      st=1476680400 rb=25433459 rp=22196 tb=1398022 tp=15691 op=0
      st=1476684000 rb=1280882 rp=2850 tb=314924 tp=2953 op=0
      st=1476687600 rb=3771652 rp=7563 tb=1028098 tp=8502 op=0
      st=1476691200 rb=31583784 rp=27185 tb=1881416 tp=20611 op=0
      st=1476694800 rb=1507592 rp=4186 tb=493020 tp=4582 op=0
      st=1476698400 rb=15009334 rp=16827 tb=1598308 tp=16659 op=0
      st=1476702000 rb=1228183 rp=3486 tb=489227 tp=4110 op=0
      st=1476705600 rb=22003336 rp=20450 tb=1435955 tp=17501 op=0
      st=1476752400 rb=59627818 rp=49589 tb=3118561 tp=37468 op=0
      st=1476756000 rb=11109759 rp=9257 tb=626997 tp=7807 op=0
      st=1476759600 rb=5337609 rp=9527 tb=1549653 tp=10394 op=0
      st=1476763200 rb=6076874 rp=11523 tb=1770616 tp=13849 op=0
      st=1476766800 rb=22972912 rp=19354 tb=1206039 tp=13779 op=0
      st=1476770400 rb=1792611 rp=3474 tb=427261 tp=4369 op=0
      st=1476774000 rb=6327239 rp=6758 tb=491623 tp=6224 op=0
      st=1476777600 rb=2702732 rp=4946 tb=555800 tp=5460 op=0
      st=1476781200 rb=8703313 rp=10332 tb=849954 tp=9787 op=0
      st=1476784800 rb=3405088 rp=3512 tb=275806 tp=3559 op=0
      st=1476788400 rb=32533869 rp=30272 tb=2038576 tp=21894 op=0
      st=1476792000 rb=1653027 rp=4739 tb=660025 tp=5997 op=0
  ident=[{type=VPN, subType=COMBINED}] uid=-1 set=ALL tag=0x0
    NetworkStatsHistory: bucketDuration=3600
      st=1476558000 rb=51223528 rp=45132 tb=3048616 tp=32746 op=0
      st=1476561600 rb=299158 rp=1053 tb=225544 tp=1265 op=0
      st=1476565200 rb=332991 rp=1462 tb=284160 tp=1896 op=0
      st=1476568800 rb=244186 rp=1125 tb=225109 tp=1447 op=0
      st=1476572400 rb=590221 rp=1893 tb=421827 tp=2398 op=0
      st=1476576000 rb=633072 rp=1730 tb=301293 tp=2108 op=0
      st=1476579600 rb=894504 rp=1871 tb=259684 tp=2146 op=0
      st=1476583200 rb=1981787 rp=2565 tb=249342 tp=2381 op=0
      st=1476586800 rb=635105 rp=1887 tb=297162 tp=2300 op=0
      st=1476590400 rb=573013 rp=1546 tb=257382 tp=1823 op=0
      st=1476594000 rb=1207198 rp=2324 tb=313524 tp=2573 op=0
      st=1476597600 rb=14472018 rp=13932 tb=1234558 tp=11886 op=0
      st=1476601200 rb=23722858 rp=22333 tb=1643754 tp=18040 op=0
      st=1476604800 rb=671305 rp=1200 tb=152283 tp=1073 op=0
      st=1476608400 rb=1120410 rp=1609 tb=125685 tp=1255 op=0
      st=1476612000 rb=2108956 rp=4148 tb=657786 tp=4526 op=0
      st=1476615600 rb=3628005 rp=7130 tb=1151445 tp=7983 op=0
      st=1476619200 rb=892601 rp=1238 tb=152874 tp=1188 op=0
      st=1476622800 rb=12036792 rp=11398 tb=855990 tp=7982 op=0
      st=1476626400 rb=2074155 rp=4369 tb=818170 tp=5251 op=0
      st=1476630000 rb=7095326 rp=10068 tb=1665577 tp=10828 op=0
      st=1476633600 rb=5957749 rp=6669 tb=750187 tp=6136 op=0
      st=1476637200 rb=160756 rp=470 tb=57276 tp=482 op=0
      st=1476640800 rb=47950670 rp=37474 tb=1253676 tp=17626 op=0
      st=1476644400 rb=146663175 rp=113191 tb=4134897 tp=64760 op=0
      st=1476648000 rb=275383 rp=1035 tb=224611 tp=1273 op=0
      st=1476651600 rb=213644 rp=912 tb=170114 tp=1172 op=0
      st=1476655200 rb=231995 rp=995 tb=174123 tp=1261 op=0
      st=1476658800 rb=326750 rp=1132 tb=251374 tp=1433 op=0
      st=1476662400 rb=754089 rp=1981 tb=324935 tp=2447 op=0
      st=1476666000 rb=95764082 rp=77561 tb=4447339 tp=46536 op=0
      st=1476669600 rb=1967641 rp=2894 tb=415008 tp=2914 op=0
      st=1476673200 rb=18452262 rp=18039 tb=1814167 tp=14227 op=0
      st=1476676800 rb=4495988 rp=6631 tb=1003620 tp=7039 op=0
      st=1476680400 rb=25033942 rp=20977 tb=988040 tp=13734 op=0
      st=1476684000 rb=1300587 rp=2816 tb=232764 tp=1930 op=0
      st=1476687600 rb=3623395 rp=6001 tb=800461 tp=6171 op=0
      st=1476691200 rb=31194368 rp=26810 tb=1337002 tp=18510 op=0
      st=1476694800 rb=1451505 rp=3509 tb=341919 tp=2926 op=0
      st=1476698400 rb=32976027 rp=33540 tb=3189012 tp=28612 op=0
      st=1476702000 rb=1159845 rp=2956 tb=353129 tp=3005 op=0
      st=1476705600 rb=22174526 rp=20253 tb=1139877 tp=15278 op=0
      st=1476709200 rb=20788246 rp=24029 tb=3091069 tp=22173 op=0
      st=1476712800 rb=26718252 rp=21118 tb=880441 tp=13935 op=0
      st=1476716400 rb=22513941 rp=19587 tb=1154954 tp=14609 op=0
      st=1476720000 rb=9721793 rp=10057 tb=925193 tp=9043 op=0
      st=1476723600 rb=58794825 rp=50311 tb=3249137 tp=37076 op=0
      st=1476727200 rb=8721089 rp=7715 tb=484374 tp=5355 op=0
      st=1476730800 rb=201986 rp=887 tb=199493 tp=1027 op=0
      st=1476734400 rb=245107 rp=972 tb=171736 tp=1241 op=0
      st=1476738000 rb=253350 rp=1021 tb=192489 tp=1323 op=0
      st=1476741600 rb=184177 rp=966 tb=173566 tp=1238 op=0
      st=1476745200 rb=474930 rp=1584 tb=308562 tp=2001 op=0
      st=1476748800 rb=8547368 rp=7735 tb=444083 tp=5579 op=0
      st=1476752400 rb=72957552 rp=61664 tb=2955332 tp=40391 op=0
      st=1476756000 rb=9713941 rp=8446 tb=373307 tp=5733 op=0
      st=1476759600 rb=6682773 rp=8985 tb=1438186 tp=8997 op=0
      st=1476763200 rb=7009634 rp=10425 tb=1620432 tp=11006 op=0
      st=1476766800 rb=22730669 rp=19034 tb=881795 tp=12112 op=0
      st=1476770400 rb=1711697 rp=2658 tb=282548 tp=2512 op=0
      st=1476774000 rb=6293999 rp=5977 tb=372053 tp=4484 op=0
      st=1476777600 rb=2675293 rp=4016 tb=448204 tp=4003 op=0
      st=1476781200 rb=8600242 rp=8754 tb=623920 tp=7060 op=0
      st=1476784800 rb=71154538 rp=59734 tb=3176362 tp=42924 op=0
      st=1476788400 rb=28362051 rp=25518 tb=1590154 tp=17545 op=0
      st=1476792000 rb=1555551 rp=3500 tb=488704 tp=4095 op=0

set=DEFAULT 表示前台的网络使用, set=BACKGROUND 表示后台的网络使用. set=ALL 意味着前台和后台都有.
tag=0x0 这个不懂,原文这么解释:indicates the socket tag associated with the traffic.
rxBytes 和 rxPackets 表示接收到的字节和数据包的数量.
txBytes 和 txPackets 表示发送的字节和数据包的数量.

展开阅读全文

没有更多推荐了,返回首页