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