[ Web Proxy ]
URL:
Viewing: https://source.android.com/docs/core/data/kernel-overview [Back]  [Original]

Kernel overview  |  Android Open Source Project Skip to main content
Android Open Source Project [Android Open Source Project]

Kernel overview Stay organized with collections Save and categorize content based on your preferences.

The per-app and delegated data usage monitoring and tracking functionality relies on the xt_qtaguid module in the android-3.0 Linux kernel (kernel/net/netfilter/xt_qtaguid). The socket tagging functionality in the framework (system/core/libcutils/qtaguid.c) relies mainly on the existence of /proc/net/xt_qtaguid/ctrl interface exported by the xt_qtaguid kernel module.

Note: Support for xt_qtaguid will be phased out starting in the Android 9 release. See eBPF Traffic Monitoring for more information.

The quota2 netfilter module (originally part of xtables-addons) allows the functionality to set named quota limits and was extended to support notifying userspace when certain limits are reached. Once the quota limit is reached, the quota2 module discards all subsequent network traffic. The framework can also specify additional rules to restrict background data traffic for an app (refer to com.android.server.NetworkManagementSocketTagger.setKernelCounterSet and android.net.NetworkPolicyManager.POLICY_REJECT_METERED_BACKGROUND).

How does it work?

The qtaguid netfilter module tracks the network traffic on a per-socket basis for every app using the unique UID of the owning app. There are two tag components associated with any socket in the system. The first is the UID which uniquely identifies the app which is responsible for the data transfer (Linux allows the ability to ascribe the ownership of each network socket to the UID of the calling app). The second tag component is used to support additional characterization of the traffic into app developer specified categories. Using these app level tags, an app can profile the traffic into several sub-categories.

In the case of apps that provide network data transfer as a service, such as the download manager, media streaming service, etc, it is possible to attribute the ownership of the network data transfer to the UID of the requesting app using the TrafficStats.setThreadStatsUid() function call. The caller must hold the android.permission.MODIFY_NETWORK_ACCOUNTING permission to re-assign the ownership of the network traffic.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-06-17 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-06-17 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page