xref: /aosp_15_r20/external/pigweed/pw_transfer/integration_test/config.proto (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker// Copyright 2022 The Pigweed Authors
2*61c4878aSAndroid Build Coastguard Worker//
3*61c4878aSAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4*61c4878aSAndroid Build Coastguard Worker// use this file except in compliance with the License. You may obtain a copy of
5*61c4878aSAndroid Build Coastguard Worker// the License at
6*61c4878aSAndroid Build Coastguard Worker//
7*61c4878aSAndroid Build Coastguard Worker//     https://www.apache.org/licenses/LICENSE-2.0
8*61c4878aSAndroid Build Coastguard Worker//
9*61c4878aSAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software
10*61c4878aSAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11*61c4878aSAndroid Build Coastguard Worker// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12*61c4878aSAndroid Build Coastguard Worker// License for the specific language governing permissions and limitations under
13*61c4878aSAndroid Build Coastguard Worker// the License.
14*61c4878aSAndroid Build Coastguard Workersyntax = "proto3";
15*61c4878aSAndroid Build Coastguard Worker
16*61c4878aSAndroid Build Coastguard Workerpackage pw.transfer;
17*61c4878aSAndroid Build Coastguard Worker
18*61c4878aSAndroid Build Coastguard Workeroption java_package = "pw.transfer";
19*61c4878aSAndroid Build Coastguard Workeroption java_outer_classname = "ConfigProtos";
20*61c4878aSAndroid Build Coastguard Worker
21*61c4878aSAndroid Build Coastguard Workerimport "pw_protobuf_protos/status.proto";
22*61c4878aSAndroid Build Coastguard Worker
23*61c4878aSAndroid Build Coastguard Workermessage TransferAction {
24*61c4878aSAndroid Build Coastguard Worker  enum ProtocolVersion {
25*61c4878aSAndroid Build Coastguard Worker    option allow_alias = true;
26*61c4878aSAndroid Build Coastguard Worker    UNKNOWN_VERSION = 0;
27*61c4878aSAndroid Build Coastguard Worker    V1 = 1;
28*61c4878aSAndroid Build Coastguard Worker    V2 = 2;
29*61c4878aSAndroid Build Coastguard Worker    LATEST = 2;
30*61c4878aSAndroid Build Coastguard Worker  }
31*61c4878aSAndroid Build Coastguard Worker
32*61c4878aSAndroid Build Coastguard Worker  // As transfers are always client initiated, TransferType is from the client's
33*61c4878aSAndroid Build Coastguard Worker  // perspective.
34*61c4878aSAndroid Build Coastguard Worker  enum TransferType {
35*61c4878aSAndroid Build Coastguard Worker    UNKNOWN = 0;
36*61c4878aSAndroid Build Coastguard Worker    WRITE_TO_SERVER = 1;
37*61c4878aSAndroid Build Coastguard Worker    READ_FROM_SERVER = 2;
38*61c4878aSAndroid Build Coastguard Worker  }
39*61c4878aSAndroid Build Coastguard Worker
40*61c4878aSAndroid Build Coastguard Worker  // Transfer resource ID to use for this transfer.
41*61c4878aSAndroid Build Coastguard Worker  uint32 resource_id = 1;
42*61c4878aSAndroid Build Coastguard Worker
43*61c4878aSAndroid Build Coastguard Worker  // Path to the file that data should be read from or written to (depending on
44*61c4878aSAndroid Build Coastguard Worker  // transfer_type). When reading from the server, this is the path the file
45*61c4878aSAndroid Build Coastguard Worker  // is written to. When writing to the server, this is the path to the file
46*61c4878aSAndroid Build Coastguard Worker  // that should be read from.
47*61c4878aSAndroid Build Coastguard Worker  string file_path = 2;
48*61c4878aSAndroid Build Coastguard Worker
49*61c4878aSAndroid Build Coastguard Worker  // Whether to write to the server, or read from it.
50*61c4878aSAndroid Build Coastguard Worker  TransferType transfer_type = 3;
51*61c4878aSAndroid Build Coastguard Worker
52*61c4878aSAndroid Build Coastguard Worker  // Expected final status of transfer operation.
53*61c4878aSAndroid Build Coastguard Worker  pw.protobuf.StatusCode expected_status = 4;
54*61c4878aSAndroid Build Coastguard Worker
55*61c4878aSAndroid Build Coastguard Worker  // Protocol version to initiate the transfer with.
56*61c4878aSAndroid Build Coastguard Worker  ProtocolVersion protocol_version = 5;
57*61c4878aSAndroid Build Coastguard Worker
58*61c4878aSAndroid Build Coastguard Worker  // Initial offset to start transfer with. Defaults to 0.
59*61c4878aSAndroid Build Coastguard Worker  uint32 initial_offset = 6;
60*61c4878aSAndroid Build Coastguard Worker}
61*61c4878aSAndroid Build Coastguard Worker
62*61c4878aSAndroid Build Coastguard Worker// Configuration for the integration test client.
63*61c4878aSAndroid Build Coastguard Workermessage ClientConfig {
64*61c4878aSAndroid Build Coastguard Worker  // The sequence of transfer actions to perform during the lifetime of this
65*61c4878aSAndroid Build Coastguard Worker  // client configuration.
66*61c4878aSAndroid Build Coastguard Worker  repeated TransferAction transfer_actions = 1;
67*61c4878aSAndroid Build Coastguard Worker
68*61c4878aSAndroid Build Coastguard Worker  // The maximum number of times this client will attempt to send a packet
69*61c4878aSAndroid Build Coastguard Worker  // before the transfer aborts due to a lack of response.
70*61c4878aSAndroid Build Coastguard Worker  uint32 max_retries = 2;
71*61c4878aSAndroid Build Coastguard Worker
72*61c4878aSAndroid Build Coastguard Worker  // The maximum time this client will wait for a response to the first
73*61c4878aSAndroid Build Coastguard Worker  // packet sent to the pw_transfer server before attempting to retry. Extending
74*61c4878aSAndroid Build Coastguard Worker  // this can help work around cases where transfer initialization takes a long
75*61c4878aSAndroid Build Coastguard Worker  // time.
76*61c4878aSAndroid Build Coastguard Worker  //
77*61c4878aSAndroid Build Coastguard Worker  // Note: This parameter is only supported on Java transfer clients.
78*61c4878aSAndroid Build Coastguard Worker  // TODO(tpudlik): google.protobuf.Duration?
79*61c4878aSAndroid Build Coastguard Worker  uint32 initial_chunk_timeout_ms = 3;
80*61c4878aSAndroid Build Coastguard Worker
81*61c4878aSAndroid Build Coastguard Worker  // The maximum amount of time this client will wait for a response to a sent
82*61c4878aSAndroid Build Coastguard Worker  // packet before attempting to re-send the packet.
83*61c4878aSAndroid Build Coastguard Worker  //
84*61c4878aSAndroid Build Coastguard Worker  // TODO(tpudlik): google.protobuf.Duration?
85*61c4878aSAndroid Build Coastguard Worker  uint32 chunk_timeout_ms = 4;
86*61c4878aSAndroid Build Coastguard Worker
87*61c4878aSAndroid Build Coastguard Worker  // Cumulative maximum number of times to retry over the course of the transfer
88*61c4878aSAndroid Build Coastguard Worker  // before giving up.
89*61c4878aSAndroid Build Coastguard Worker  uint32 max_lifetime_retries = 5;
90*61c4878aSAndroid Build Coastguard Worker}
91*61c4878aSAndroid Build Coastguard Worker
92*61c4878aSAndroid Build Coastguard Worker// Stacks of paths to use when doing transfers. Each new initiated transfer
93*61c4878aSAndroid Build Coastguard Worker// on this resource gets the next file path in the stack. Once the stack is
94*61c4878aSAndroid Build Coastguard Worker// exhausted, new transfers on this resource fail as though this resource is
95*61c4878aSAndroid Build Coastguard Worker// unregistered.
96*61c4878aSAndroid Build Coastguard Workermessage ServerResourceLocations {
97*61c4878aSAndroid Build Coastguard Worker  // When a client reads from this server, this stack is used to determine which
98*61c4878aSAndroid Build Coastguard Worker  // file path to read data from.
99*61c4878aSAndroid Build Coastguard Worker  repeated string source_paths = 3;
100*61c4878aSAndroid Build Coastguard Worker
101*61c4878aSAndroid Build Coastguard Worker  // When a client writes to this server, this stack is used to determine which
102*61c4878aSAndroid Build Coastguard Worker  // file path to write data to.
103*61c4878aSAndroid Build Coastguard Worker  repeated string destination_paths = 4;
104*61c4878aSAndroid Build Coastguard Worker
105*61c4878aSAndroid Build Coastguard Worker  // If source_paths is exhausted or empty, this source path can be reused
106*61c4878aSAndroid Build Coastguard Worker  // as a fallback indefinitely.
107*61c4878aSAndroid Build Coastguard Worker  string default_source_path = 5;
108*61c4878aSAndroid Build Coastguard Worker
109*61c4878aSAndroid Build Coastguard Worker  // If destination_paths is exhausted or empty, this destination path can be
110*61c4878aSAndroid Build Coastguard Worker  // reused as a fallback indefinitely.
111*61c4878aSAndroid Build Coastguard Worker  string default_destination_path = 6;
112*61c4878aSAndroid Build Coastguard Worker
113*61c4878aSAndroid Build Coastguard Worker  // Defines whether or not the resource can be read from an offset
114*61c4878aSAndroid Build Coastguard Worker  bool offsettable = 7;
115*61c4878aSAndroid Build Coastguard Worker}
116*61c4878aSAndroid Build Coastguard Worker
117*61c4878aSAndroid Build Coastguard Worker// Configuration for the integration test server.
118*61c4878aSAndroid Build Coastguard Workermessage ServerConfig {
119*61c4878aSAndroid Build Coastguard Worker  // A mapping of transfer resource ID to files to read from or write to.
120*61c4878aSAndroid Build Coastguard Worker  map<uint32, ServerResourceLocations> resources = 1;
121*61c4878aSAndroid Build Coastguard Worker
122*61c4878aSAndroid Build Coastguard Worker  // Size of the chunk buffer used by this server's transfer thread, in bytes.
123*61c4878aSAndroid Build Coastguard Worker  uint32 chunk_size_bytes = 2;
124*61c4878aSAndroid Build Coastguard Worker
125*61c4878aSAndroid Build Coastguard Worker  // Window size, in bytes.
126*61c4878aSAndroid Build Coastguard Worker  uint32 pending_bytes = 3;
127*61c4878aSAndroid Build Coastguard Worker
128*61c4878aSAndroid Build Coastguard Worker  // TODO(tpudlik): google.protobuf.Duration?
129*61c4878aSAndroid Build Coastguard Worker  uint32 chunk_timeout_seconds = 4;
130*61c4878aSAndroid Build Coastguard Worker  uint32 transfer_service_retries = 5;
131*61c4878aSAndroid Build Coastguard Worker  uint32 extend_window_divisor = 6;
132*61c4878aSAndroid Build Coastguard Worker}
133*61c4878aSAndroid Build Coastguard Worker
134*61c4878aSAndroid Build Coastguard Worker// Configuration for the HdlcPacketizer proxy filter.
135*61c4878aSAndroid Build Coastguard Workermessage HdlcPacketizerConfig {}
136*61c4878aSAndroid Build Coastguard Worker
137*61c4878aSAndroid Build Coastguard Worker// Configuration for the DataDropper proxy filter.
138*61c4878aSAndroid Build Coastguard Workermessage DataDropperConfig {
139*61c4878aSAndroid Build Coastguard Worker  // Rate at which to drop data
140*61c4878aSAndroid Build Coastguard Worker  float rate = 1;
141*61c4878aSAndroid Build Coastguard Worker
142*61c4878aSAndroid Build Coastguard Worker  // Seed to use for the rand number generator used for determining
143*61c4878aSAndroid Build Coastguard Worker  // when data is dropped.
144*61c4878aSAndroid Build Coastguard Worker  int64 seed = 2;
145*61c4878aSAndroid Build Coastguard Worker}
146*61c4878aSAndroid Build Coastguard Worker
147*61c4878aSAndroid Build Coastguard Worker// Configuration for the KeepDropQueue proxy filter.
148*61c4878aSAndroid Build Coastguard Workermessage KeepDropQueueConfig {
149*61c4878aSAndroid Build Coastguard Worker  // A KeepDropQueue filter will alternate between keeping packets and dropping
150*61c4878aSAndroid Build Coastguard Worker  // chunks of data based on a keep/drop queue provided during its creation. The
151*61c4878aSAndroid Build Coastguard Worker  // queue is looped over unless a negative element is found. A negative number
152*61c4878aSAndroid Build Coastguard Worker  // is effectively the same as a value of infinity.
153*61c4878aSAndroid Build Coastguard Worker  //
154*61c4878aSAndroid Build Coastguard Worker  // This filter is typically most pratical when used with a packetizer so data
155*61c4878aSAndroid Build Coastguard Worker  // can be dropped as distinct packets.
156*61c4878aSAndroid Build Coastguard Worker  //
157*61c4878aSAndroid Build Coastguard Worker  // Examples:
158*61c4878aSAndroid Build Coastguard Worker  //
159*61c4878aSAndroid Build Coastguard Worker  //   keep_drop_queue = [3, 2]:
160*61c4878aSAndroid Build Coastguard Worker  //     Keeps 3 packets,
161*61c4878aSAndroid Build Coastguard Worker  //     Drops 2 packets,
162*61c4878aSAndroid Build Coastguard Worker  //     Keeps 3 packets,
163*61c4878aSAndroid Build Coastguard Worker  //     Drops 2 packets,
164*61c4878aSAndroid Build Coastguard Worker  //     ... [loops indefinitely]
165*61c4878aSAndroid Build Coastguard Worker  //
166*61c4878aSAndroid Build Coastguard Worker  //   keep_drop_queue = [5, 99, 1, -1]:
167*61c4878aSAndroid Build Coastguard Worker  //     Keeps 5 packets,
168*61c4878aSAndroid Build Coastguard Worker  //     Drops 99 packets,
169*61c4878aSAndroid Build Coastguard Worker  //     Keeps 1 packet,
170*61c4878aSAndroid Build Coastguard Worker  //     Drops all further packets.
171*61c4878aSAndroid Build Coastguard Worker  repeated int32 keep_drop_queue = 1;
172*61c4878aSAndroid Build Coastguard Worker
173*61c4878aSAndroid Build Coastguard Worker  // If true, only transfer chunks will be counted as part of the keep/drop
174*61c4878aSAndroid Build Coastguard Worker  // cycle. All other types of data received will always be forwarded.
175*61c4878aSAndroid Build Coastguard Worker  // Useful for testing specific transfer failure modes. Defaults to false.
176*61c4878aSAndroid Build Coastguard Worker  bool only_consider_transfer_chunks = 2;
177*61c4878aSAndroid Build Coastguard Worker}
178*61c4878aSAndroid Build Coastguard Worker
179*61c4878aSAndroid Build Coastguard Worker// Configuration for the RateLimiter proxy filter.
180*61c4878aSAndroid Build Coastguard Workermessage RateLimiterConfig {
181*61c4878aSAndroid Build Coastguard Worker  // Rate limit, in bytes/sec.
182*61c4878aSAndroid Build Coastguard Worker  float rate = 1;
183*61c4878aSAndroid Build Coastguard Worker}
184*61c4878aSAndroid Build Coastguard Worker
185*61c4878aSAndroid Build Coastguard Worker// Configuration for the DataTransposer proxy filter.
186*61c4878aSAndroid Build Coastguard Workermessage DataTransposerConfig {
187*61c4878aSAndroid Build Coastguard Worker  // Rate at which to transpose data.  Probability of transposition
188*61c4878aSAndroid Build Coastguard Worker  // between 0.0 and 1.0.
189*61c4878aSAndroid Build Coastguard Worker  float rate = 1;
190*61c4878aSAndroid Build Coastguard Worker
191*61c4878aSAndroid Build Coastguard Worker  // Maximum time a chunk of data will be held for Transposition.  After this
192*61c4878aSAndroid Build Coastguard Worker  // time has elapsed, the packet is sent in order.
193*61c4878aSAndroid Build Coastguard Worker  float timeout = 2;
194*61c4878aSAndroid Build Coastguard Worker
195*61c4878aSAndroid Build Coastguard Worker  // Seed to use for the rand number generator used for determining
196*61c4878aSAndroid Build Coastguard Worker  // when data is transposed.
197*61c4878aSAndroid Build Coastguard Worker  int64 seed = 3;
198*61c4878aSAndroid Build Coastguard Worker}
199*61c4878aSAndroid Build Coastguard Worker
200*61c4878aSAndroid Build Coastguard Worker// Configuration for the ServerFailure proxy filter.
201*61c4878aSAndroid Build Coastguard Workermessage ServerFailureConfig {
202*61c4878aSAndroid Build Coastguard Worker  // A list of numbers of packets to send before dropping all subsequent
203*61c4878aSAndroid Build Coastguard Worker  // packets until a TRANSFER_START packet is seen.  This process is
204*61c4878aSAndroid Build Coastguard Worker  // repeated for each element in packets_before_failure.  After that list
205*61c4878aSAndroid Build Coastguard Worker  // is exhausted, ServerFailure will send all packets.
206*61c4878aSAndroid Build Coastguard Worker  repeated uint32 packets_before_failure = 1;
207*61c4878aSAndroid Build Coastguard Worker
208*61c4878aSAndroid Build Coastguard Worker  // By default, the ServerFailure starts counting packets after receiving a
209*61c4878aSAndroid Build Coastguard Worker  // transfer START packet. If `start_immediately` is set to `true`, the filter
210*61c4878aSAndroid Build Coastguard Worker  // will begin counting packets as soon as it is initialized, before the first
211*61c4878aSAndroid Build Coastguard Worker  // START is seen.
212*61c4878aSAndroid Build Coastguard Worker  bool start_immediately = 2;
213*61c4878aSAndroid Build Coastguard Worker
214*61c4878aSAndroid Build Coastguard Worker  // If true, `packets_before_failure` will only be incremented when a transfer
215*61c4878aSAndroid Build Coastguard Worker  // chunk is processed, and only transfer chunks will be dropped once the limit
216*61c4878aSAndroid Build Coastguard Worker  // is reached. All other types of data received will always be forwarded.
217*61c4878aSAndroid Build Coastguard Worker  // Useful for testing specific transfer failure modes. Defaults to false.
218*61c4878aSAndroid Build Coastguard Worker  bool only_consider_transfer_chunks = 3;
219*61c4878aSAndroid Build Coastguard Worker}
220*61c4878aSAndroid Build Coastguard Worker
221*61c4878aSAndroid Build Coastguard Worker// Configuration for the WindowPacketDropper proxy filter.
222*61c4878aSAndroid Build Coastguard Workermessage WindowPacketDropperConfig {
223*61c4878aSAndroid Build Coastguard Worker  // The nth packet of every window to drop.
224*61c4878aSAndroid Build Coastguard Worker  uint32 window_packet_to_drop = 1;
225*61c4878aSAndroid Build Coastguard Worker}
226*61c4878aSAndroid Build Coastguard Worker
227*61c4878aSAndroid Build Coastguard Worker// Configuration for a single stage in the proxy filter stack.
228*61c4878aSAndroid Build Coastguard Workermessage FilterConfig {
229*61c4878aSAndroid Build Coastguard Worker  oneof filter {
230*61c4878aSAndroid Build Coastguard Worker    HdlcPacketizerConfig hdlc_packetizer = 1;
231*61c4878aSAndroid Build Coastguard Worker    DataDropperConfig data_dropper = 2;
232*61c4878aSAndroid Build Coastguard Worker    RateLimiterConfig rate_limiter = 3;
233*61c4878aSAndroid Build Coastguard Worker    DataTransposerConfig data_transposer = 4;
234*61c4878aSAndroid Build Coastguard Worker    ServerFailureConfig server_failure = 5;
235*61c4878aSAndroid Build Coastguard Worker    KeepDropQueueConfig keep_drop_queue = 6;
236*61c4878aSAndroid Build Coastguard Worker    WindowPacketDropperConfig window_packet_dropper = 7;
237*61c4878aSAndroid Build Coastguard Worker  }
238*61c4878aSAndroid Build Coastguard Worker}
239*61c4878aSAndroid Build Coastguard Worker
240*61c4878aSAndroid Build Coastguard Workermessage ProxyConfig {
241*61c4878aSAndroid Build Coastguard Worker  // Filters are listed in order of execution.  I.e. the first filter listed
242*61c4878aSAndroid Build Coastguard Worker  // will get the received data first then pass it on the the second listed
243*61c4878aSAndroid Build Coastguard Worker  // filter. That process repeats until the last filter send the data to the
244*61c4878aSAndroid Build Coastguard Worker  // other side of the proxy.
245*61c4878aSAndroid Build Coastguard Worker  repeated FilterConfig client_filter_stack = 1;
246*61c4878aSAndroid Build Coastguard Worker  repeated FilterConfig server_filter_stack = 2;
247*61c4878aSAndroid Build Coastguard Worker}
248