• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2022 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://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,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package netsim.frontend;
18
19import "google/protobuf/empty.proto";
20
21import "model.proto";
22
23/**
24 * The frontend service for the network simulator.
25 *
26 * The network simulator interconnects virtual radio controllers on emulated
27 * android and accessory devices to allows control of the topology, device
28 * positions, and RF characteristics.
29 *
30 * Clients of the frontend service include a Command Line Interface (cli), Mobly
31 * scripts, and a web UI.
32 *
33 */
34service FrontendService {
35  // Get the version of the netsim service.
36  rpc GetVersion(google.protobuf.Empty) returns (VersionResponse);
37
38  // Register for device movement and emulated radio state events
39  rpc RegisterEvents(google.protobuf.Empty) returns (stream Event);
40
41  // Get a list of devices
42  rpc GetDevices(google.protobuf.Empty) returns (GetDevicesResponse);
43
44  // Patch a device
45  rpc PatchDevice(PatchDeviceRequest) returns (google.protobuf.Empty);
46
47  // Reset all devices.
48  rpc Reset(google.protobuf.Empty) returns (google.protobuf.Empty);
49
50  // TODO: Other hwsim commands - addAccessPoint, addLink, ...
51
52  // Methods not implement yet.
53
54  // Set a simplified Link Loss Model
55  rpc SetLinkLoss(SetLinkLossRequest) returns (google.protobuf.Empty);
56
57  // Radio properties (simplified view of txpower)
58  // Set the specified emulated radio chip's range.
59
60  // Register for network logs
61  rpc NetCat(google.protobuf.Empty) returns (stream NetCatStream);
62
63  // Patch a Capture source to turn capture on/off.
64  // When turned on the old capture contents are replaced.
65  rpc PatchCapture(PatchCaptureRequest) returns (google.protobuf.Empty);
66
67  // List all Captures currently connected on netsim.
68  rpc ListCapture(google.protobuf.Empty) returns (ListCaptureResponse);
69
70  // Retrieve the contents of the packet capture as streaming bytes
71  rpc GetCapture(GetCaptureRequest) returns (stream GetCaptureResponse);
72}
73
74message VersionResponse {
75  string version = 1;
76}
77
78// Set a fixed error probabilities for a link, where a value of 0% is
79// a perfect medium.  This is a simple model that does not take into
80// account losses due to transmission rates and signal-to-noise ratio.
81message SetLinkLossRequest {
82  string device_name = 1;
83  string other_device = 2;
84  netsim.model.PhyKind radio = 3;
85  // As a percent between 0 and 1
86  float link_loss = 4;
87}
88
89message PatchDeviceRequest {
90  netsim.model.Device device = 2;  // by id or name
91}
92
93// Event when simulation state changes.
94message Event {
95  repeated netsim.model.Device devices = 1;
96}
97
98// Response for GetDevices request.
99//
100// Returns the emulators and accessory devices that are connected to
101// the network simulator.
102message GetDevicesResponse {
103  repeated netsim.model.Device devices = 1;
104}
105
106// Response to the NetCat request.
107//
108// NetCat provides a streaming log of network operations.
109message NetCatStream {
110  repeated string result = 1;
111}
112
113message SetPacketCaptureRequest {
114  bool capture = 1;
115  string device_serial = 2;
116}
117
118message PatchCaptureRequest {
119  int32 id = 1;
120
121  // Body of PatchCapture that will be channeled into
122  // body for HandleCaptureCxx
123  message PatchCapture {
124    netsim.model.State state = 1;
125  }
126
127  PatchCapture patch = 2;
128}
129
130message ListCaptureResponse {
131  repeated netsim.model.Capture captures = 1;
132}
133
134message GetCaptureRequest {
135  int32 id = 1;
136}
137
138message GetCaptureResponse {
139  bytes capture_stream = 1;
140}
141
142message ErrorResponse {
143  int32 code = 1;
144  string error_message = 2;
145  string status = 3;
146}