[SailfishDevel] network statistics for sailfish
W. Dobbe
winfried.dobbe at xmsnet.nl
Mon Dec 16 23:04:21 UTC 2013
On 16 Dec 2013, at 23:40, Thomas Perl <th.perl at gmail.com> wrote:
> Hey,
>
> 2013/12/16 Martin Grimme <martin.grimme at gmail.com>:
>> 2013/12/16, W. Dobbe <winfried.dobbe at xmsnet.nl>:
>>> Probably that will be the end conclusion, but Android is also Linux, so how
>>> do the Android network monitor apps get their information? Does the android
>>> stack/Dalvik give extra hooks for network inspection ?
>>
>> Android is not Linux. Android is as much Linux as iOS is BSD.
>> Android runs on top of a Linux kernel, but that's all Android and
>> GNU/Linux have in common.
>> Network inspection is probably exposed by the Android Java API.
>
> In Android, every application has its own UID, so the "bandwidth per
> app" problem can be reduced to "bandwidth per user" in that case. If
> you look around the Android sources, there's a way to access these
> stats:
>
> https://github.com/CyanogenMod/android_frameworks_base/blob/cm-10.2/core/java/android/net/NetworkStats.java
>
> And this is how the stats are collected:
>
> https://github.com/CyanogenMod/android_frameworks_base/blob/cm-10.2/services/java/com/android/server/net/NetworkStatsCollection.java
> https://github.com/CyanogenMod/android_frameworks_base/blob/cm-10.2/services/java/com/android/server/net/NetworkStatsRecorder.java
> https://github.com/CyanogenMod/android_frameworks_base/blob/cm-10.2/services/java/com/android/server/net/NetworkStatsService.java
>
Hi Thomas, thanks a lot for the insight in Androids monitoring. I have 0 experience with Android myself.
> With that said, it's definitely possible with some motivation to do
> per-process bandwidth tracking, we did something like this for a Uni
> course some years ago:
>
> http://thp.io/2010/bwmon/
>
> This uses the "ip_conntrack" kernel module or - with more recent
> kernels - conntrack-tools:
>
> http://conntrack-tools.netfilter.org/
>
> There's even some documentation on how to use the bwmon utility:
>
> http://thp.io/2010/bwmon/manual.html
>
> If you plan on using that for the mobile device use case, think about
> rewriting the thing in C/C++ instead of Python and make it less
> resource-hungry by reducing wake-ups. As Harbour apps are now prefixed
> with "harbour-" and have strict requirements for .desktop and icon
> file naming, it should be easy to make a system that calculates
> per-app bandwidth usage and shows the icon of the app and the name of
> the app without too much work.
>
Hmm, I didn't know conntrack. I'll have a look at that. At first sight it still looks like you need root privileges for conntrack though :-(
The problem is not to get the stats, if Nethog can do it, so can a Sailfish app. Problem is to do it in such a way that it will be accepted in Harbour.
Still, some more leads to investigate this week. Thanks.
>
> HTH :)
> Thomas
More information about the Devel
mailing list