TrafficStats具体应用 - 特定的网络接口 [英] TrafficStats Specific application - specific network interface

查看:97
本文介绍了TrafficStats具体应用 - 特定的网络接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以使用trafficstats API以下方法来获取发送的字节和针对任何给定应用程序所有的网络接口接收。但是,如何才能获得唯一的移动统计?所以,我可以单独移动和WiFi数据。

I know I can use the following methods of trafficstats api to get bytes sent and received for ALL network interfaces for any given app. But how do I get stats for only mobile? So that I can seperate mobile and wifi data.

getUidTxBytes(INT UID)结果
  获得通过发送的字节数
  网络这个UID。

getUidTxBytes(int uid)
Get the number of bytes sent through the network for this UID.

getUidRxBytes(INT UID)结果
  获得通过所接收的字节数
  网络这个UID。

getUidRxBytes(int uid)
Get the number of bytes received through the network for this UID.

好像这样的事情是从API失踪。和其他方式得到它
getUidMobileRxBytes(INT UID)

Seems like something like this is missing from API. And other way to get it getUidMobileRxBytes(int uid)

推荐答案

很抱歉,但你只能得到每个接口的统计整个设备,而不是每个UID。

Sorry, but you can only get per-interface stats for the entire device, not per UID.

您可以按接口,每个UID统计所收集的所有接口,每个UID统计和每个接口,整个设备的统计两者,则假定接口为整个设备的比例是估算约,这将是该个体的UID的比率。对短的时间跨度,这很可能是相当准确的,因为设备将只周期性地开关接口

You can estimate per-interface, per-UID stats by collecting both the all-interface, per-UID stats and the per-interface, whole-device stats, then assuming that the ratio of the interfaces for the whole device is approximately the ratio that would be for that individual UID. For short time spans, this is likely to be fairly accurate, as the device will only switch interfaces periodically.

这篇关于TrafficStats具体应用 - 特定的网络接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆