1/*
2 * Copyright (C) 2023 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 android.os.statsd.threadnetwork;
20
21import "frameworks/proto_logging/stats/atom_field_options.proto";
22
23option java_package = "com.android.os.threadnetwork";
24option java_multiple_files = true;
25
26// Thread Telemetry data definition.
27message ThreadnetworkTelemetryDataReported {
28  message WpanStats {
29    optional int32 phy_rx = 1;
30    optional int32 phy_tx = 2;
31    optional int32 mac_unicast_rx = 3;
32    optional int32 mac_unicast_tx = 4;
33    optional int32 mac_broadcast_rx = 5;
34    optional int32 mac_broadcast_tx = 6;
35    optional int32 mac_tx_ack_req = 7;
36    optional int32 mac_tx_no_ack_req = 8;
37    optional int32 mac_tx_acked = 9;
38    optional int32 mac_tx_data = 10;
39    optional int32 mac_tx_data_poll = 11;
40    optional int32 mac_tx_beacon = 12;
41    optional int32 mac_tx_beacon_req = 13;
42    optional int32 mac_tx_other_pkt = 14;
43    optional int32 mac_tx_retry = 15;
44    optional int32 mac_rx_data = 16;
45    optional int32 mac_rx_data_poll = 17;
46    optional int32 mac_rx_beacon = 18;
47    optional int32 mac_rx_beacon_req = 19;
48    optional int32 mac_rx_other_pkt = 20;
49    optional int32 mac_rx_filter_whitelist = 21;
50    optional int32 mac_rx_filter_dest_addr = 22;
51    optional int32 mac_tx_fail_cca = 23;
52    optional int32 mac_rx_fail_decrypt = 24;
53    optional int32 mac_rx_fail_no_frame = 25;
54    optional int32 mac_rx_fail_unknown_neighbor = 26;
55    optional int32 mac_rx_fail_invalid_src_addr = 27;
56    optional int32 mac_rx_fail_fcs = 28;
57    optional int32 mac_rx_fail_other = 29;
58    optional int32 ip_tx_success = 30;
59    optional int32 ip_rx_success = 31;
60    optional int32 ip_tx_failure = 32;
61    optional int32 ip_rx_failure = 33;
62    optional uint32 node_type = 34;
63    optional uint32 channel = 35;
64    optional int32 radio_tx_power = 36;
65    optional float mac_cca_fail_rate = 37;
66  }
67
68  message WpanTopoFull {
69    optional uint32 rloc16 = 1;
70    optional uint32 router_id = 2;
71    optional uint32 leader_router_id = 3;
72    optional uint32 leader_rloc16 = 4; // replaced optional bytes leader_address = 5;
73    optional uint32 leader_weight = 5;
74    optional uint32 leader_local_weight = 6;
75    optional uint32 preferred_router_id = 7;
76    optional uint32 partition_id = 8;
77    optional uint32 child_table_size = 9;
78    optional uint32 neighbor_table_size = 10;
79    optional int32 instant_rssi = 11;
80    optional bool has_extended_pan_id = 12;
81    optional bool is_active_br = 13;
82    optional bool is_active_srp_server = 14;
83    optional uint32 sum_on_link_prefix_changes = 15;
84  }
85
86  enum NodeType {
87    NODE_TYPE_UNSPECIFIED = 0;
88    NODE_TYPE_ROUTER = 1;
89    NODE_TYPE_END = 2;
90    NODE_TYPE_SLEEPY_END = 3;
91    NODE_TYPE_MINIMAL_END = 4;
92
93    NODE_TYPE_OFFLINE = 5;
94    NODE_TYPE_DISABLED = 6;
95    NODE_TYPE_DETACHED = 7;
96
97    NODE_TYPE_NL_LURKER = 0x10;
98    NODE_TYPE_COMMISSIONER = 0x20;
99    NODE_TYPE_LEADER = 0x40;
100  }
101
102  message PacketsAndBytes {
103    optional int64 packet_count = 1;
104    optional int64 byte_count = 2;
105  }
106
107  message Nat64TrafficCounters {
108    optional int64 ipv4_to_ipv6_packets = 1;
109    optional int64 ipv4_to_ipv6_bytes = 2;
110    optional int64 ipv6_to_ipv4_packets = 3;
111    optional int64 ipv6_to_ipv4_bytes = 4;
112  }
113
114  message Nat64ProtocolCounters {
115    optional Nat64TrafficCounters tcp = 1;
116    optional Nat64TrafficCounters udp = 2;
117    optional Nat64TrafficCounters icmp = 3;
118  }
119
120  message Nat64PacketCounters {
121    optional int64 ipv4_to_ipv6_packets = 1;
122    optional int64 ipv6_to_ipv4_packets = 2;
123  }
124
125  message Nat64ErrorCounters {
126    optional Nat64PacketCounters unknown = 1;
127    optional Nat64PacketCounters illegal_packet = 2;
128    optional Nat64PacketCounters unsupported_protocol = 3;
129    optional Nat64PacketCounters no_mapping = 4;
130  }
131
132  message BorderRoutingCounters {
133    // The number of Router Advertisement packets received by otbr-agent on the
134    // infra link
135    optional int64 ra_rx = 1;
136
137    // The number of Router Advertisement packets successfully transmitted by
138    // otbr-agent on the infra link.
139    optional int64 ra_tx_success = 2;
140
141    // The number of Router Advertisement packets failed to transmit by
142    // otbr-agent on the infra link.
143    optional int64 ra_tx_failure = 3;
144
145    // The number of Router Solicitation packets received by otbr-agent on the
146    // infra link
147    optional int64 rs_rx = 4;
148
149    // The number of Router Solicitation packets successfully transmitted by
150    // otbr-agent on the infra link.
151    optional int64 rs_tx_success = 5;
152
153    // The number of Router Solicitation packets failed to transmit by
154    // otbr-agent on the infra link.
155    optional int64 rs_tx_failure = 6;
156
157    // The counters for inbound unicast packets
158    optional PacketsAndBytes inbound_unicast = 7;
159
160    // The counters for inbound multicast packets
161    optional PacketsAndBytes inbound_multicast = 8;
162
163    // The counters for outbound unicast packets
164    optional PacketsAndBytes outbound_unicast = 9;
165
166    // The counters for outbound multicast packets
167    optional PacketsAndBytes outbound_multicast = 10;
168
169    // The inbound and outbound NAT64 traffic through the border router
170    optional Nat64ProtocolCounters nat64_protocol_counters = 11;
171
172    // Error counters for NAT64 translator on the border router
173    optional Nat64ErrorCounters nat64_error_counters = 12;
174  }
175
176  message SrpServerRegistrationInfo {
177    // The number of active hosts/services registered on the SRP server.
178    optional uint32 fresh_count = 1;
179
180    // The number of hosts/services in 'Deleted' state on the SRP server.
181    optional uint32 deleted_count = 2;
182
183    // The sum of lease time in milliseconds of all active hosts/services on the
184    // SRP server.
185    optional uint64 lease_time_total_ms = 3;
186
187    // The sum of key lease time in milliseconds of all active hosts/services on
188    // the SRP server.
189    optional uint64 key_lease_time_total_ms = 4;
190
191    // The sum of remaining lease time in milliseconds of all active
192    // hosts/services on the SRP server.
193    optional uint64 remaining_lease_time_total_ms = 5;
194
195    // The sum of remaining key lease time in milliseconds of all active
196    // hosts/services on the SRP server.
197    optional uint64 remaining_key_lease_time_total_ms = 6;
198  }
199
200  message SrpServerResponseCounters {
201    // The number of successful responses
202    optional uint32 success_count = 1;
203
204    // The number of server failure responses
205    optional uint32 server_failure_count = 2;
206
207    // The number of format error responses
208    optional uint32 format_error_count = 3;
209
210    // The number of 'name exists' responses
211    optional uint32 name_exists_count = 4;
212
213    // The number of refused responses
214    optional uint32 refused_count = 5;
215
216    // The number of other responses
217    optional uint32 other_count = 6;
218  }
219
220  enum SrpServerState {
221    SRP_SERVER_STATE_UNSPECIFIED = 0;
222    SRP_SERVER_STATE_DISABLED = 1;
223    SRP_SERVER_STATE_RUNNING = 2;
224    SRP_SERVER_STATE_STOPPED = 3;
225  }
226
227  // The address mode used by the SRP server
228  enum SrpServerAddressMode {
229    SRP_SERVER_ADDRESS_MODE_UNSPECIFIED = 0;
230    SRP_SERVER_ADDRESS_MODE_UNICAST = 1;
231    SRP_SERVER_ADDRESS_MODE_STATE_ANYCAST = 2;
232  }
233
234  message SrpServerInfo {
235    // The state of the SRP server
236    optional SrpServerState state = 1;
237
238    // Listening port number
239    optional uint32 port = 2;
240    // The address mode {unicast, anycast} of the SRP server
241    optional SrpServerAddressMode address_mode = 3;
242
243    // The registration information of hosts on the SRP server
244    optional SrpServerRegistrationInfo hosts = 4;
245
246    // The registration information of services on the SRP server
247    optional SrpServerRegistrationInfo services = 5;
248
249    // The counters of response codes sent by the SRP server
250    optional SrpServerResponseCounters response_counters = 6;
251  }
252
253  message DnsServerResponseCounters {
254    // The number of successful responses
255    optional uint32 success_count = 1;
256
257    // The number of server failure responses
258    optional uint32 server_failure_count = 2;
259
260    // The number of format error responses
261    optional uint32 format_error_count = 3;
262
263    // The number of name error responses
264    optional uint32 name_error_count = 4;
265
266    // The number of 'not implemented' responses
267    optional uint32 not_implemented_count = 5;
268
269    // The number of other responses
270    optional uint32 other_count = 6;
271  }
272
273  message DnsServerInfo {
274    // The counters of response codes sent by the DNS server
275    optional DnsServerResponseCounters response_counters = 1;
276
277    // The number of DNS queries resolved at the local SRP server
278    optional uint32 resolved_by_local_srp_count = 2;
279  }
280
281  message MdnsResponseCounters {
282    // The number of successful responses
283    optional uint32 success_count = 1;
284
285    // The number of 'not found' responses
286    optional uint32 not_found_count = 2;
287
288    // The number of 'invalid arg' responses
289    optional uint32 invalid_args_count = 3;
290
291    // The number of 'duplicated' responses
292    optional uint32 duplicated_count = 4;
293
294    // The number of 'not implemented' responses
295    optional uint32 not_implemented_count = 5;
296
297    // The number of unknown error responses
298    optional uint32 unknown_error_count = 6;
299
300    // The number of aborted responses
301    optional uint32 aborted_count = 7;
302
303    // The number of invalid state responses
304    optional uint32 invalid_state_count = 8;
305  }
306
307  message MdnsInfo {
308    // The response counters of host registrations
309    optional MdnsResponseCounters host_registration_responses = 1;
310
311    // The response counters of service registrations
312    optional MdnsResponseCounters service_registration_responses = 2;
313
314    // The response counters of host resolutions
315    optional MdnsResponseCounters host_resolution_responses = 3;
316
317    // The response counters of service resolutions
318    optional MdnsResponseCounters service_resolution_responses = 4;
319
320    // The EMA (Exponential Moving Average) latencies of mDNS operations
321
322    // The EMA latency of host registrations in milliseconds
323    optional uint32 host_registration_ema_latency_ms = 5;
324
325    // The EMA latency of service registrations in milliseconds
326    optional uint32 service_registration_ema_latency_ms = 6;
327
328    // The EMA latency of host resolutions in milliseconds
329    optional uint32 host_resolution_ema_latency_ms = 7;
330
331    // The EMA latency of service resolutions in milliseconds
332    optional uint32 service_resolution_ema_latency_ms = 8;
333  }
334
335  enum Nat64State {
336    NAT64_STATE_UNSPECIFIED = 0;
337    NAT64_STATE_DISABLED = 1;
338    NAT64_STATE_NOT_RUNNING = 2;
339    NAT64_STATE_IDLE = 3;
340    NAT64_STATE_ACTIVE = 4;
341  }
342
343  message BorderRoutingNat64State {
344    optional Nat64State prefix_manager_state = 1;
345    optional Nat64State translator_state = 2;
346  }
347
348  message WpanBorderRouter {
349    // Border routing counters
350    optional BorderRoutingCounters border_routing_counters = 1;
351
352    // Information about the SRP server
353    optional SrpServerInfo srp_server = 2;
354
355    // Information about the DNS server
356    optional DnsServerInfo dns_server = 3;
357
358    // Information about the mDNS publisher
359    optional MdnsInfo mdns = 4;
360
361    // Information about the state of components of NAT64
362    optional BorderRoutingNat64State nat64_state = 5;
363  }
364
365  message RcpStabilityStatistics {
366    optional uint32 rcp_timeout_count = 1;
367    optional uint32 rcp_reset_count = 2;
368    optional uint32 rcp_restoration_count = 3;
369    optional uint32 spinel_parse_error_count = 4;
370    optional int32 rcp_firmware_update_count = 5;
371    optional uint32 thread_stack_uptime = 6;
372  }
373
374  message RcpInterfaceStatistics {
375    optional uint32 rcp_interface_type = 1;
376    optional uint64 transferred_frames_count = 2;
377    optional uint64 transferred_valid_frames_count = 3;
378    optional uint64 transferred_garbage_frames_count = 4;
379    optional uint64 rx_frames_count = 5;
380    optional uint64 rx_bytes_count = 6;
381    optional uint64 tx_frames_count = 7;
382    optional uint64 tx_bytes_count = 8;
383  }
384
385  message WpanRcp {
386    optional RcpStabilityStatistics rcp_stability_statistics = 1;
387    optional RcpInterfaceStatistics rcp_interface_statistics = 2;
388  }
389
390  message CoexMetrics {
391    optional uint32 count_tx_request = 1;
392    optional uint32 count_tx_grant_immediate = 2;
393    optional uint32 count_tx_grant_wait = 3;
394    optional uint32 count_tx_grant_wait_activated = 4;
395    optional uint32 count_tx_grant_wait_timeout = 5;
396    optional uint32 count_tx_grant_deactivated_during_request = 6;
397    optional uint32 tx_average_request_to_grant_time_us = 7;
398    optional uint32 count_rx_request = 8;
399    optional uint32 count_rx_grant_immediate = 9;
400    optional uint32 count_rx_grant_wait = 10;
401    optional uint32 count_rx_grant_wait_activated = 11;
402    optional uint32 count_rx_grant_wait_timeout = 12;
403    optional uint32 count_rx_grant_deactivated_during_request = 13;
404    optional uint32 count_rx_grant_none = 14;
405    optional uint32 rx_average_request_to_grant_time_us = 15;
406  }
407
408  optional WpanStats wpan_stats = 1 [(log_mode) = MODE_BYTES];
409  optional WpanTopoFull wpan_topo_full = 2 [(log_mode) = MODE_BYTES];
410  optional WpanBorderRouter wpan_border_router = 3 [(log_mode) = MODE_BYTES];
411  optional WpanRcp wpan_rcp = 4 [(log_mode) = MODE_BYTES];
412  optional CoexMetrics coex_metrics = 5 [(log_mode) = MODE_BYTES];
413}
414
415message ThreadnetworkTopoEntryRepeated {
416  message TopoEntry {
417    // 0~15: uint16_t rloc_16
418    // 16~31: uint16_t version Thread version of the neighbor
419    optional uint32 combo_telemetry1 = 1;
420    // 0~7: uint8_t link_quality_in
421    // 8~15: int8_t average_rssi
422    // 16~23: int8_t last_rssi
423    // 24~31: uint8_t network_data_version
424    optional uint32 combo_telemetry2 = 2;
425    optional uint32 age_sec = 3;
426    // Each bit on the flag represents a bool flag
427    // 0: rx_on_when_idle
428    // 1: full_function
429    // 2: secure_data_request
430    // 3: full_network_data
431    // 4: is_child
432    optional uint32 topo_entry_flags = 4;
433    optional uint32 link_frame_counter = 5;
434    optional uint32 mle_frame_counter = 6;
435    optional uint32 timeout_sec = 7;
436    // 0~15: uint16_t frame_error_rate. Frame error rate (0xffff->100%). Requires error tracking feature.
437    // 16~31: uint16_t message_error_rate. (IPv6) msg error rate (0xffff->100%). Requires error tracking feature.
438    optional uint32 combo_telemetry3 = 8;
439  }
440
441  message TopoEntryRepeated {
442    repeated TopoEntry topo_entries = 1;
443  }
444
445  optional TopoEntryRepeated topo_entry_repeated = 1 [(log_mode) = MODE_BYTES];
446}
447
448message ThreadnetworkDeviceInfoReported {
449  // OpenThread host build version.
450  optional string ot_host_version = 1;
451
452  // OpenThread RCP build version.
453  optional string ot_rcp_version = 2;
454
455  // Thread protocol version.
456  optional int32 thread_version = 3;
457
458  // Thread Daemon version.
459  optional string thread_daemon_version = 4;
460}
461