• 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
60// NetworkPacketBundle bundles one or more packets sharing the same attributes.
61message NetworkPacketBundle {
62  oneof packet_context {
63    // The intern id for looking up the associated packet context.
64    uint64 iid = 1;
65
66    // The inlined context for events in this bundle.
67    NetworkPacketEvent ctx = 2;
68  }
69
70  // The timestamp of the i-th packet encoded as the nanoseconds since the
71  // enclosing TracePacket's timestamp.
72  repeated uint64 packet_timestamps = 3 [packed = true];
73
74  // The length of the i-th packet in bytes (wire_size - L2_header_size).
75  repeated uint32 packet_lengths = 4 [packed = true];
76
77  // Total number of packets in the bundle (when above aggregation_threshold).
78  optional uint32 total_packets = 5;
79
80  // Duration between first and last packet (when above aggregation_threshold).
81  optional uint64 total_duration = 6;
82
83  // Total packet length in bytes (when above aggregation_threshold).
84  optional uint64 total_length = 7;
85}
86
87// An internable packet context.
88message NetworkPacketContext {
89  optional uint64 iid = 1;
90  optional NetworkPacketEvent ctx = 2;
91}
92