1//
2// Copyright (C) 2018 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";
18
19package com_android_server_wifi;
20
21option java_package = "com.android.server.wifi.proto";
22option java_outer_classname = "WifiScoreCardProto";
23
24message NetworkList {
25  optional int64 start_time_millis = 1; // Start of collection period
26  optional int64 end_time_millis = 2;   // End of collection period
27  // A collection of network descriptions
28  repeated Network networks = 3;
29};
30
31// Describes a network, consisting of a collection of access points that share
32// the same SSID, the same security type, and (hopefully) the same L3 subnet.
33// This message is not stored in the MemoryStore. It is used to package
34// the access points of a network together in dumpsys output or similar.
35// For this purpose, the network_config_id and network_agent_id may be useful
36// for cross-referencing with other parts of the bug report. Neither of these
37// are meaningful across reboots.
38message Network {
39  optional string ssid = 1;                // The SSID (not stored)
40  optional SecurityType security_type = 2; // Wireless security type
41  repeated AccessPoint access_points = 3;  // The list of related APs
42  optional int32 network_config_id = 4;    // The networkId of WifiConfiguration
43  optional int32 network_agent_id = 5;     // Latest NetworkAgent netId
44  optional NetworkStats network_stats = 6; // Network stats of current SSID
45};
46
47// Describes an access point (single BSSID)
48//
49// Beyond the BSSID, a concise id is assigned to track references
50// among APs. These ids are local to the device, but unique among all APs
51// known to the device. The BSSID itself is not stored in persistent storage.
52message AccessPoint {
53  optional int32 id = 1;               // Concise id
54  optional bytes bssid = 2;            // BSSID of the access point (not stored)
55  optional SecurityType security_type = 6; // Wireless security type
56  reserved 3;
57  repeated Signal event_stats = 4;     // Statistics taken at specific events
58  reserved 5;
59};
60
61// Describes the IEEE 802.11 security type
62enum SecurityType {
63    OPEN = 0;         // Open - no encryption
64    WEP = 1;          // Should not be used
65    PSK = 2;          // WPA2
66    EAP = 3;          // Extensible Authentication Protocol
67    SAE = 4;          // WPA3
68    EAP_SUITE_B = 5;
69    OWE = 6;          // Opportunistic Wireless Encryption
70};
71
72// Records statistics gathered at various points in the life-cycle of
73// a connection, e.g., at disconnections of various flavors. May be
74// further split out by frequency.
75//
76message Signal {
77  optional Event event = 1;                   // Type of the event
78  optional int32 frequency = 2;               // Frequency (MHz)
79  optional UnivariateStatistic rssi = 3;      // Signal strength (dBm) of beacons
80  optional UnivariateStatistic linkspeed = 4; // Link speed (Mbits/sec)
81  optional UnivariateStatistic elapsed_ms = 5; // Milliseconds since connection attempt
82};
83
84// Statistics about a real value
85message UnivariateStatistic {
86  // Short-term statistics (for current collection period)
87  optional int64 count = 1;           // Number of events
88  optional double sum = 2;            // Sum of values
89  optional double sum_of_squares = 3; // Sum of squares of values
90  optional double min_value = 4;      // Minimum value during period
91  optional double max_value = 5;      // Maximum value during period
92
93  // Long-term statistics
94  // These are accumulated over a longer time span, and are aged so that
95  // more recent measurements get a higher weight.
96  optional double historical_mean = 6;     // Long-term average
97  optional double historical_variance = 7; // Long-term variance
98
99  // Arranged by increasing value
100  repeated HistogramBucket buckets = 8;
101};
102
103message HistogramBucket {
104  // Lower bound (inclusive) for values falling in this bucket.
105  // Compact signed encoding used here, because rssi values are negative.
106  // The upper bound is not stored explicitly.
107  optional sint64 low = 1;
108  // Number of occurences for this value or bucket.
109  optional int64 number = 2;
110}
111
112// Events where statistics may be collected
113enum Event {
114  SIGNAL_POLL = 1;
115  SCAN_BEFORE_SUCCESSFUL_CONNECTION = 2;
116  FIRST_POLL_AFTER_CONNECTION = 3;
117  IP_CONFIGURATION_SUCCESS = 4;
118  SCAN_BEFORE_FAILED_CONNECTION = 5;
119  CONNECTION_FAILURE = 6;
120  IP_REACHABILITY_LOST = 7;
121  LAST_POLL_BEFORE_ROAM = 8;
122  ROAM_SUCCESS = 9;
123  WIFI_DISABLED = 10;
124  ROAM_FAILURE = 11;
125  LAST_POLL_BEFORE_SWITCH = 12;
126  VALIDATION_SUCCESS = 13;
127  DISCONNECTION = 14;
128  CONNECTION_ATTEMPT = 15;
129  VALIDATION_FAILURE = 16;
130};
131
132message SystemInfoStats {
133  // Current software build information
134  optional SoftwareBuildInfo curr_software_build_info = 1;
135  // Previous software build information
136  optional SoftwareBuildInfo prev_software_build_info = 2;
137  // Most recent WiFi scan time
138  optional int64 last_scan_time_ms = 3;
139  // Number of access points found in most recent WiFi scan at 2G
140  optional int32 num_bssid_last_scan_2g = 4;
141  // Number of access points found in most recent WiFi scan above 2G
142  optional int32 num_bssid_last_scan_above_2g = 5;
143}
144
145message SoftwareBuildInfo {
146  // Android OS build version
147  optional string os_build_version = 1;
148  // WiFi stack APK version, 0 means not available.
149  optional int64 wifi_stack_version = 2;
150  // WiFi driver version
151  optional string wifi_driver_version = 3;
152  // WiFi firmware version
153  optional string wifi_firmware_version = 4;
154}
155
156message NetworkStats {
157  optional int32 id = 1;    // Concise id
158  // The most recent connection stats with current SW build that may be collected over days
159  optional ConnectionStats recent_stats = 2;
160  // Accumulated connection stats with current SW build
161  optional ConnectionStats stats_curr_build = 3;
162  // Accumulated connection stats with previous SW build
163  optional ConnectionStats stats_prev_build = 4;
164  // List of frequencies observed for this network from scan results, sorted by most recent first.
165  repeated int32 frequencies = 5;
166
167};
168
169message ConnectionStats {
170  // Number of connection attempts at high RSSI
171  optional int32 num_connection_attempt = 1;
172  // Number of connection failures at high RSSI
173  // Does not include wrong password but does include DHCP
174  optional int32 num_connection_failure = 2;
175  // Total connection duration in seconds
176  optional int32 connection_duration_sec = 3;
177  // Number of association rejections at high RSSI
178  optional int32 num_association_rejection = 4;
179  // Number of association timeouts at high RSSI
180  optional int32 num_association_timeout = 5;
181  // Number of authentication failures (excluding wrong password) at high RSSI
182  optional int32 num_authentication_failure = 6;
183  // Number of short connections caused by nonlocal disconnection at high RSSI
184  // or at high Tx speed with a recent RSSI poll
185  optional int32 num_short_connection_nonlocal = 7;
186  // Number of non-locally generated disconnections at high RSSI or Tx speed
187  // with a recent RSSI poll
188  optional int32 num_disconnection_nonlocal = 8;
189  // Number of disconnections with a recent RSSI poll
190  optional int32 num_disconnection = 9;
191}
192