// Copyright 2022 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. syntax = "proto3"; package netsim.frontend; import "google/protobuf/empty.proto"; import "model.proto"; /** * The frontend service for the network simulator. * * The network simulator interconnects virtual radio controllers on emulated * android and accessory devices to allows control of the topology, device * positions, and RF characteristics. * * Clients of the frontend service include a Command Line Interface (cli), Mobly * scripts, and a web UI. * */ service FrontendService { // Get the version of the netsim service. rpc GetVersion(google.protobuf.Empty) returns (VersionResponse); // Register for device movement and emulated radio state events rpc RegisterEvents(google.protobuf.Empty) returns (stream Event); // Get a list of devices rpc GetDevices(google.protobuf.Empty) returns (GetDevicesResponse); // Patch a device rpc PatchDevice(PatchDeviceRequest) returns (google.protobuf.Empty); // Reset all devices. rpc Reset(google.protobuf.Empty) returns (google.protobuf.Empty); // TODO: Other hwsim commands - addAccessPoint, addLink, ... // Methods not implement yet. // Set a simplified Link Loss Model rpc SetLinkLoss(SetLinkLossRequest) returns (google.protobuf.Empty); // Radio properties (simplified view of txpower) // Set the specified emulated radio chip's range. // Register for network logs rpc NetCat(google.protobuf.Empty) returns (stream NetCatStream); // Patch a Capture source to turn capture on/off. // When turned on the old capture contents are replaced. rpc PatchCapture(PatchCaptureRequest) returns (google.protobuf.Empty); // List all Captures currently connected on netsim. rpc ListCapture(google.protobuf.Empty) returns (ListCaptureResponse); // Retrieve the contents of the packet capture as streaming bytes rpc GetCapture(GetCaptureRequest) returns (stream GetCaptureResponse); } message VersionResponse { string version = 1; } // Set a fixed error probabilities for a link, where a value of 0% is // a perfect medium. This is a simple model that does not take into // account losses due to transmission rates and signal-to-noise ratio. message SetLinkLossRequest { string device_name = 1; string other_device = 2; netsim.model.PhyKind radio = 3; // As a percent between 0 and 1 float link_loss = 4; } message PatchDeviceRequest { netsim.model.Device device = 2; // by id or name } // Event when simulation state changes. message Event { repeated netsim.model.Device devices = 1; } // Response for GetDevices request. // // Returns the emulators and accessory devices that are connected to // the network simulator. message GetDevicesResponse { repeated netsim.model.Device devices = 1; } // Response to the NetCat request. // // NetCat provides a streaming log of network operations. message NetCatStream { repeated string result = 1; } message SetPacketCaptureRequest { bool capture = 1; string device_serial = 2; } message PatchCaptureRequest { int32 id = 1; // Body of PatchCapture that will be channeled into // body for HandleCaptureCxx message PatchCapture { netsim.model.State state = 1; } PatchCapture patch = 2; } message ListCaptureResponse { repeated netsim.model.Capture captures = 1; } message GetCaptureRequest { int32 id = 1; } message GetCaptureResponse { bytes capture_stream = 1; } message ErrorResponse { int32 code = 1; string error_message = 2; string status = 3; }