English

gRPC

Updated on Apr 2, 2024 by
72

What Is gRPC?

gRPC, an open-source RPC software framework developed by Google, offers high-performance communication utilizing the HTTP/2 transport layer protocol. With a versatile API design approach, gRPC facilitates the management and configuration of network devices. It supports multiple programming languages, including C, Java, Golang, and Python.

In practical applications, gRPC can be effectively combined with telemetry to serve as a data transmission protocol, enabling real-time and high-speed monitoring of network device operations. Furthermore, gRPC provides methods for configuration, querying, and obtaining device capabilities, allowing connected devices to report their data to a collector.

How Does gRPC Work?

gRPC Protocol Architecture

gRPC, an implementation of Remote Procedure Call (RPC) APIs, empowers developers to focus on services without the burden of managing the underlying communication infrastructure. As an open-source framework, gRPC allows both parties involved in communication to perform secondary development based on the framework. In the depicted diagram, gRPC encapsulates information at various layers, ensuring efficient data transmission while the DATA layer carries service module data.

Operations Supported by gRPC

There are two modes in which a device can connect to a collector: dial-in and dial-out modes.

Dial-in mode: In this mode, the device acts as a gRPC server while the collector functions as a gRPC client. The collector initiates a gRPC connection request to the device to retrieve data or deliver configurations. This mode is suitable for small-scale networks.

The following operations can be performed in dial-in mode:

  • 1. Subscribe: This operation collects interface traffic statistics, CPU usage, and memory usage of the device at a high speed. Currently, telemetry is the only supported method for performing this operation.

  • 2. Get: This operation retrieves the running status and configuration of the device. Currently, the gRPC Network Management Interface (gNMI) protocol is the only supported method for performing this operation.

  • 3. Capabilities: This operation obtains the capabilities of the device. Currently, gNMI is the only supported method for performing this operation.

  • 4. Set: This operation delivers configurations to the device. Currently, gNMI is the only supported method for performing this operation.

Dial-out mode: In this mode, the device acts as a gRPC client while the collector functions as a gRPC server. The device proactively establishes a gRPC connection with the collector to push the subscribed data, configured on the device, to the collector. This mode only supports the subscribe operation based on telemetry and is suitable for large-scale networks.

gRPC Interaction Process

In the depicted illustration, gRPC operates on the client/server model, where a network device acts as a gRPC client and a collector functions as a gRPC server. The following outlines the process of gRPC interaction:

A gRPC-enabled device serves as a client, while a collector operates as a server. The device prepares the data format (GPB/JSON) based on the application service, such as the subscribed event. It compiles a .proto file using ProtoBuf. Subsequently, the device establishes a gRPC channel with the collector and transmits a request message via gRPC.

Upon receiving the request message, the collector leverages ProtoBuf to parse the .proto file and reconstructs the predefined data structure for further service processing.

After processing the data, the collector employs ProtoBuf to compile the response data and transmits a response message to the device via gRPC.

Upon receiving the response message, the device concludes the gRPC interaction. In essence, the device establishes an active gRPC connection with the collector to push the subscribed data, as configured on the device, to the collector. Throughout the entire gRPC interaction process, both the device and the collector utilize ProtoBuf to define the .proto file.

标签

How can gRPC be applied in practice?

The subscription function (Subscribe operation) is facilitated by RPC using telemetry technology. Telemetry enables the remote collection of data from physical or virtual devices at a high speed. In push mode, devices periodically transmit interface traffic statistics, CPU usage, and memory usage to collectors.

In the presented diagram, a gRPC connection is established between the Network Management System (NMS) and the network device, allowing the NMS to subscribe to data from a specific module on the device. Telemetry supports both dynamic subscription and static subscription, which are utilized in the dial-in and dial-out modes, respectively.

标签

Telemetry implementation process:

1.Users have the option to define either a static or dynamic telemetry subscription.

  • Static telemetry subscription: Defined within the huawei-grpc-dialout.proto file.

  • Dynamic telemetry subscription: Defined within the huawei-grpc-dialin.proto file.

Users encode the collected information in either GPB or JSON format and define essential details such as the sampling path and timestamp within the huawei-telemetry.proto file.

  • When using the GPB format, the encoding field in the huawei-telemetry.proto file is set to 0 (indicating GPB encoding). The sampled data is carried in GPB format within the data_gpb field, while the data_str field remains empty.

  • When using the JSON format, the encoding field in the huawei-telemetry.proto file is set to 1 (indicating JSON encoding). The sampled data is carried in JSON format within the data_str field, while the data_gpb field remains empty.

3.The device transmits the data to the collector, which then proceeds to decode and analyze the received data.

  • The data_gpb field within the huawei-telemetry.proto file requires decoding using the corresponding service's .proto file. The specific .proto file is determined by the sensor_path field in the huawei-telemetry.proto file. For example, if the sensor_path field value is huawei-ifm:ifm/interfaces/interface, the corresponding .proto file would be huawei-ifm.proto.

  • If the pure JSON encoding format (both the telemetry layer and data model layer using JSON encoding) is employed, users only need to decode the huawei-grpc-dialout.proto or huawei-grpc-dialin.proto file. In the case of the hybrid JSON encoding format (telemetry layer using GPB and data model layer using JSON encoding), users need to decode the huawei-grpc-dialout.proto or huawei-grpc-dialin.proto file along with the huawei-telemetry.proto file. The .proto file for a specific service is not required in this scenario.

Tags

You might be interested in

See profile for undefined.
FS Official
AI Firewall
See profile for undefined.
FS Official
VPN
See profile for undefined.
FS Official
VPC