1/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17syntax = "proto2";
18option java_multiple_files = true;
19
20package com.android.networkstack.metrics;
21
22import "frameworks/proto_logging/stats/enums/stats/connectivity/network_stack.proto";
23
24message CapportApiData {
25    // The TTL of the network connection provided by captive portal
26    optional int32 remaining_ttl_secs = 1;
27
28    // The limit traffic data of the network connection provided by captive portal
29    optional int32 remaining_bytes = 2;
30
31    // Is portal url option included in the DHCP packet (Yes, No)
32    optional bool has_portal_url = 3;
33
34    // Is venue info (e.g. store info, maps, flight status) included (Yes, No)
35    optional bool has_venue_info = 4;
36}
37
38message ProbeEvent {
39    // The probe type (http or https, or captive portal API...)
40    optional .android.stats.connectivity.ProbeType probe_type = 1;
41
42    // The latency in microseconds of the probe event
43    optional int32 latency_micros = 2;
44
45    // The result of the probe event
46    optional .android.stats.connectivity.ProbeResult probe_result = 3;
47
48    // The CaptivePortal API info
49    optional CapportApiData capport_api_data = 4;
50}
51
52message ProbeEvents {
53    // Record probe event during the validation
54    repeated ProbeEvent probe_event = 1;
55}
56
57/**
58 * The DHCP (Dynamic Host Configuration Protocol) session info
59 * Logged from:
60 * src/android/net/dhcp/DhcpClient.java
61 */
62message DhcpSession {
63    // The DHCP Feature(s) enabled in this session
64    repeated .android.stats.connectivity.DhcpFeature used_features = 1;
65
66    // The discover packet (re)transmit count
67    optional int32 discover_count = 2;
68
69    // The request packet (re)transmit count
70    optional int32 request_count = 3;
71
72    // The IPv4 address conflict count
73    // (only be meaningful when duplicate address detection is enabled)
74    optional int32 conflict_count = 4;
75
76    // The DHCP packet parsing error code in this session
77    // (defined in android.net.metrics.DhcpErrorEvent)
78    repeated .android.stats.connectivity.DhcpErrorCode error_code = 5;
79
80    // The result of DHCP hostname transliteration
81    optional .android.stats.connectivity.HostnameTransResult ht_result = 6;
82}
83
84/**
85 * Logs Network IP provisioning event
86 * Logged from:
87 * src/com/android/networkstack/metrics/NetworkIpProvisioningMetrics.java
88 */
89message NetworkIpProvisioningReported {
90    // Transport type (WIFI, CELLULAR, BLUETOOTH, ..)
91    optional .android.stats.connectivity.TransportType transport_type = 1;
92
93    // The latency in microseconds of IP Provisioning over IPV4
94    optional int32 ipv4_latency_micros = 2;
95
96    // The latency in microseconds of IP Provisioning over IPV6
97    optional int32 ipv6_latency_micros = 3;
98
99    // The time duration between provisioning start and end (success or failure)
100    optional int64 provisioning_duration_micros = 4;
101
102    // The specific disconnect reason for this IP provisioning
103    optional .android.stats.connectivity.DisconnectCode disconnect_code = 5;
104
105    // Log DHCP session info (Only valid for IPv4)
106    optional DhcpSession dhcp_session = 6;
107
108    // The random number between 0 ~ 999 for sampling
109    optional int32 random_number = 7;
110
111    // Check which IPv6 provisioning mode is used for current connection
112    optional .android.stats.connectivity.Ipv6ProvisioningMode ipv6_provisioning_mode = 8;
113}
114
115/**
116 * Logs Network DHCP Renew event
117 * Logged from:
118 * src/android/net/dhcp/DhcpClient.java
119 */
120message NetworkDhcpRenewReported {
121    // Transport type (WIFI, CELLULAR, BLUETOOTH, ..)
122    optional .android.stats.connectivity.TransportType transport_type = 1;
123
124    // The request packet (re)transmit count
125    optional int32 request_count = 2;
126
127    // The latency in microseconds of DHCP Renew
128    optional int32 latency_micros = 3;
129
130    // The DHCP error code is defined in android.net.metrics.DhcpErrorEvent
131    optional .android.stats.connectivity.DhcpErrorCode error_code = 4;
132
133    // The result of DHCP renew
134    optional .android.stats.connectivity.DhcpRenewResult renew_result = 5;
135
136    // The random number between 0 ~ 999 for sampling
137    optional int32 random_number = 6;
138}
139
140/**
141 * Logs Network Validation event
142 * Logged from:
143 * src/com/android/server/connectivity/NetworkMonitor.java
144 */
145message NetworkValidationReported {
146    // Transport type (WIFI, CELLULAR, BLUETOOTH, ..)
147    optional .android.stats.connectivity.TransportType transport_type = 1;
148
149    // Record each probe event
150    optional ProbeEvents probe_events = 2;
151
152    // The result of the network validation
153    optional .android.stats.connectivity.ValidationResult validation_result = 3;
154
155    // The latency in microseconds of network validation
156    optional int32 latency_micros = 4;
157
158    // The validation index (the first validation attempt or second, third...)
159    optional int32 validation_index = 5;
160
161    // The random number between 0 ~ 999 for sampling
162    optional int32 random_number = 6;
163}
164
165/**
166 * Logs NetworkStack Quirk event
167 * Logged from:
168 * src/com/android/networkstack/
169 * This will be defined as count metrics on server side
170 */
171message NetworkStackQuirkReported {
172    // Transport type (WIFI, CELLULAR, BLUETOOTH, ..)
173    optional .android.stats.connectivity.TransportType transport_type = 1;
174
175    // Record each Quirk event
176    optional .android.stats.connectivity.NetworkQuirkEvent event = 2;
177}
178
179/**
180 * Logs Neighbor Unreachability Detection probe event.
181 * Logged from:
182 * src/com/android/networkstack/metrics/IpReachabilityMonitorMetrics.java
183 */
184message NetworkIpReachabilityMonitorReported {
185    // Neighbor Unreachability Detection event.
186    optional .android.stats.connectivity.NudEventType event_type = 1;
187
188    // NUD probe based on IPv4 ARP or IPv6 ND packet.
189    optional .android.stats.connectivity.IpType ip_type = 2;
190
191    // NUD neighbor type, default gateway, DNS server or both.
192    optional .android.stats.connectivity.NudNeighborType neighbor_type = 3;
193}
194
195/**
196 * Logs Ip client RA(Router Advertisement) info
197 * Logged from:
198 * packages/modules/NetworkStack/src/android/net/ip/IpClient.java
199 */
200message IpClientRaInfoReported {
201    // The maximum number of distinct RAs (Router Advertisements).
202    optional int32 max_number_of_distinct_ras = 1;
203
204    // The number of zero lifetime RAs (Router Advertisements).
205    optional int32 number_of_zero_lifetime_ras = 2;
206
207    // The number of parsing error for RAs (Router Advertisements).
208    optional int32 number_of_parsing_error_ras = 3;
209
210    // The lowest router lifetime in seconds, excluding 0.
211    optional int32 lowest_router_lifetime_seconds = 4;
212
213    // The lowest valid lifetime of PIO (Prefix Information Option) in seconds, excluding 0.
214    optional int64 lowest_pio_valid_lifetime_seconds = 5;
215
216    // The lowest route lifetime of RIO (Route Information Option) in seconds, excluding 0.
217    optional int64 lowest_rio_route_lifetime_seconds = 6;
218
219    // The lowest lifetime of RDNSS (Recursive DNS Server Option) in seconds, excluding 0.
220    optional int64 lowest_rdnss_lifetime_seconds = 7;
221}
222
223/**
224 * Logs value of the APF counter.
225 */
226message ApfCounter {
227    // The name of APF counter.
228    optional .android.stats.connectivity.CounterName counter_name = 1;
229
230    // The value of APF counter.
231    optional int64 counter_value = 2;
232}
233
234
235message ApfCounterList {
236    repeated ApfCounter apf_counter = 1;
237}
238
239/**
240 * Logs APF session information event.
241 * Logged from:
242 * packages/modules/NetworkStack/src/android/net/apf/ApfFilter.java or
243 * packages/modules/NetworkStack/src/android/net/apf/LegacyApfFilter.java
244 */
245message ApfSessionInfoReported {
246    // The version of APF, where version = -1 equals APF disable.
247    optional int32 version = 1;
248
249    // The memory size of APF module.
250    optional int32 memory_size = 2;
251
252    // The values of all APF counters.
253    optional ApfCounterList apf_counter_list = 3;
254
255    // The duration of APF session in seconds.
256    optional int32 apf_session_duration_seconds = 4;
257
258    // Number of times APF program updated.
259    optional int32 num_of_times_apf_program_updated = 5;
260
261    // Record the maximum of program size.
262    optional int32 max_program_size = 6;
263}
264