• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 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 perfetto.protos;
20
21enum TrafficDirection {
22  DIR_UNSPECIFIED = 0;
23  DIR_INGRESS = 1;
24  DIR_EGRESS = 2;
25}
26
27// NetworkPacketEvent records the details of a single packet sent or received
28// on the network (in Linux kernel terminology, one sk_buff struct).
29message NetworkPacketEvent {
30  // The direction traffic is flowing for this event.
31  optional TrafficDirection direction = 1;
32
33  // The name of the interface if available (e.g. 'rmnet0').
34  optional string interface = 2;
35
36  // The length of the packet in bytes (wire_size - L2_header_size). Ignored
37  // when using NetworkPacketEvent as the ctx in either NetworkPacketBundle or
38  // NetworkPacketContext.
39  optional uint32 length = 3;
40
41  // The Linux user id associated with the packet's socket.
42  optional uint32 uid = 4;
43
44  // The Android network tag associated with the packet's socket.
45  optional uint32 tag = 5;
46
47  // The packet's IP protocol (TCP=6, UDP=17, etc).
48  optional uint32 ip_proto = 6;
49
50  // The packet's TCP flags as a bitmask (FIN=0x1, SYN=0x2, RST=0x4, etc).
51  optional uint32 tcp_flags = 7;
52
53  // The local udp/tcp port of the packet.
54  optional uint32 local_port = 8;
55
56  // The remote udp/tcp port of the packet.
57  optional uint32 remote_port = 9;
58
59  // The 1-byte ICMP type identifier.
60  optional uint32 icmp_type = 10;
61
62  // The 1-byte ICMP code identifier.
63  optional uint32 icmp_code = 11;
64}
65
66// NetworkPacketBundle bundles one or more packets sharing the same attributes.
67message NetworkPacketBundle {
68  oneof packet_context {
69    // The intern id for looking up the associated packet context.
70    uint64 iid = 1;
71
72    // The inlined context for events in this bundle.
73    NetworkPacketEvent ctx = 2;
74  }
75
76  // The timestamp of the i-th packet encoded as the nanoseconds since the
77  // enclosing TracePacket's timestamp.
78  repeated uint64 packet_timestamps = 3 [packed = true];
79
80  // The length of the i-th packet in bytes (wire_size - L2_header_size).
81  repeated uint32 packet_lengths = 4 [packed = true];
82
83  // Total number of packets in the bundle (when above aggregation_threshold).
84  optional uint32 total_packets = 5;
85
86  // Duration between first and last packet (when above aggregation_threshold).
87  optional uint64 total_duration = 6;
88
89  // Total packet length in bytes (when above aggregation_threshold).
90  optional uint64 total_length = 7;
91}
92
93// An internable packet context.
94message NetworkPacketContext {
95  optional uint64 iid = 1;
96  optional NetworkPacketEvent ctx = 2;
97}
98