Network statistics on Nexus 7

一笑奈何 提交于 2020-01-17 02:50:15

问题


I want to read the network statistics on my Nexus 7 from the file system. On all devices tested before, the network statistics (e.g., tx_packets) were always located in

/sys/devices/virtual/net/wlan

However, although on the Nexus 7 there are four matching sub directories

/sys/devices/virtual/net/dummy
/sys/devices/virtual/net/ip6tnl0
/sys/devices/virtual/net/lo
/sys/devices/virtual/net/sit0

none of them seems to provide the right statistics, as all their statistic files do not change during Web access via WiFi.

Any sugestions where I might look as well?


回答1:


try the directory: /sys/class/net/iface/statistics/tx_packets

Example for wlan0

long txPackets= 0; //tx Packets
String cmd="cat /sys/class/net/wlan0/statistics/tx_packets\n";
Process p=null;
BufferedReader in2=null;

try {
    p = Runtime.getRuntime().exec(cmd);
    in2 = new BufferedReader(new InputStreamReader(p.getInputStream()));
    txPackets= Long.parseLong(in2.readLine());  
}catch (Exception e)
{
    // TODO: handle exception
    e.printStackTrace();
}


来源:https://stackoverflow.com/questions/12854866/network-statistics-on-nexus-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!