目录

netcopilot

netcopilot is designed to assist you in network simulation. It allows you to directly call related APIs via hdc command-line interface (CLI) to simulate preset network scenarios.

The netcopilot tool is supported since API version 20.

Before using the netcopilot tool, you need to obtain the hdc tool.

How to Use

[h2]Command Syntax

hdc shell netcopilot <Parameter> <Sub-parameter>

The following table lists the command parameters and sub-parameters. You can also run the hdc shell command and then run the netcopilot request.

[h2]Parameter List

CLI Parameters Sub-parameter Function Description
-h NA Outputs help information. NA
-e 0: off; 1: on Enables or disables netcopilot. When this switch is disabled, other options are unavailable.
-p NA Prints the list of network scenarios.

By default, the list of preset network simulation scenarios is printed.

In & out of elevator

Leave home WLAN range

Enter home WLAN range

Busy cafeteria

Parking garage

Riding the subway

Riding high-speed train (switching between SIM cards)

Highway driving

-s Scenario ID Starts a network simulation.

You can switch between different network simulation scenarios.

Network simulations must meet the corresponding network adapter requirements. For scenarios such as using the elevator, disconnecting WLAN when leaving home, or connecting WLAN when arriving home, both WLAN and cellular networks must be connected. For all other scenarios, either WLAN or cellular networks need to be connected.

-c Scenario ID Cancels a network simulation. NA
-P Scenario ID Prints details about a custom scenario. Only custom scenarios are supported.
-a Details about a custom scenario Adds a custom scenario.

Adds a custom scenario using a JSON string. The following is an example of the format:

{

"scenarioName": "Custom scenario",

"uplinkBandwidth": 1000000,

"downlinkBandwidth": 5000000,

"uplinkLatency": 200,

"downlinkLatency": 200,

"uplinkDropRate": 0.05,

"downlinkDropRate": 0.01

}

-d Custom scenario ID Deletes a custom scenario. The custom scenario ID is generated by netcopilot backend. After obtaining the ID from the list using -p, you can delete the scenario using -d.

Usage Examples

[h2]Displaying Help Information

> hdc shell netcopilot -h
netcopilot usage:
  -h : show help message
  -e <enable>: 0 for disable, 1 for enable
  -p : print all scenario info
  -s <scenario id>: simulate specified network scenario
  -c : cancel simulating scenario
  -P <scenario id>: print specified scenario details
  -a <custom scenario details>: add custom network scenario
  -d <scenario id>: delete custom network scenario

[h2]Enabling or Disabling netcopilot

> hdc shell netcopilot -e 0
Disable netcopilot success

> hdc shell netcopilot -e 1
Enable netcopilot success

[h2]Viewing the List of Network Scenarios

> hdc shell netcopilot -p
  +------------+------------------------------+
  | ScenarioID | ScenarioName                 |
  +------------+------------------------------+
  1            | In & out of elevator
  2            | Leave home WLAN range
  3            | Enter home WLAN range
  4            | Busy cafeteria
  5            | Parking garage
  6            | Riding the subway
  7            | Riding high-speed train (switching between SIM cards)
  8            | Highway driving
  +------------+------------------------------+

[h2]Starting Network Simulation

> hdc shell netcopilot -s 4
Success to simulate scenario 4

[h2]Canceling Network Simulation

> hdc shell netcopilot -c 4
Clear active net scenario success

[h2]Adding a Custom Scenario

> hdc shell netcopilot -a "{\"scenarioName\":\"Custom scenario 1\",\"uplinkBandwidth\":100000,\"downlinkBandwidth\":500000,\"uplinkLatency\":200,\"downlinkLatency\":200,\"uplinkDropRate\":0.05,\"downlinkDropRate\":0.01}"

The sub-parameters of the custom scenario need to be converted into JSON character strings.

[h2]Viewing the Details of a Custom Scenario

> hdc shell netcopilot -P 1000
Scenario Name: Custom scenario 1
Uplink Bandwidth: 100000Kbps
Downlink Bandwidth: 500000Kbps
Uplink Latency: 200ms
Downlink Latency: 200ms
Uplink Drop Rate: 0.05%
Downlink Drop Rate: 0.01%

[h2]Deleting a Custom Scenario

> hdc shell netcopilot -d 1000
Delete custom scenario success