| <html devsite><head> |
| <title>流量消耗标签说明</title> |
| <meta name="project_path" value="/_project.yaml"/> |
| <meta name="book_path" value="/_book.yaml"/> |
| </head> |
| <body> |
| <!-- |
| Copyright 2017 The Android Open Source Project |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <p>标签是跟踪流量消耗计数器的指标之一。默认情况下,标签仅以隐性方式基于 UID。UID 被用作监管的基础,不容忽视。因此,标签始终至少代表一个 UID (uid_tag)。可以通过与 UID 关联的“帐号标签”明确增强某个标签。用户空间可以使用 <code>TrafficStats.setThreadStatsTag()</code> 设置标签的 acct_tag 部分,然后将标签与套接字配合使用:属于相应套接字的所有数据都将被计入该标签。之后,监管基于该标签的 uid_tag 部分,并单独收集 acct_tag 部分的统计信息。</p> |
| <p>如果没有显式标记,则 qtaguid 模块将假设 <code>default_tag: {acct_tag=0, uid_tag=10003}</code></p> |
| <pre class="devsite-click-to-copy"> |
| a: {acct_tag=1, uid_tag=10003} |
| b: {acct_tag=2, uid_tag=10003} |
| c: {acct_tag=3, uid_tag=10003} |
| </pre> |
| <p><code>a, b, c…</code> 表示与特定套接字关联的显式标签。</p> |
| <p><code>default_tag (acct_tag=0)</code> 是包含相应 uid 的总流量(包括所有未标记的流量)的默认帐号标签,通常用于强制执行监管/配额规则。</p> |
| <p>这些标签可用于将应用的网络流量划分到独立的逻辑类别中(在网络套接字级别)。可在运行时移除、重新应用或修改这些标签。</p> |
| <p>qtaguid 模块已在 <a href="https://android-review.googlesource.com/#/q/project:kernel/common+branch:android-3.0,n,z">kernel/common branch:android-3.0</a> 上实现</p> |
| |
| </body></html> |