Support for the Google Protocol Buffers (GPB) Encoding Format
Google Protocol Buffers (GPB) encoding is a language-neutral, platform-neutral, and extensible mechanism for serializing structured data of communications protocols and data storage.
Telemetry uses the encoding format GPB (the file name extension of a file encoded in GPB format is .proto) and provides a mechanism for serializing structured data flexibly, efficiently, and automatically. The GPB format is binary encoding and has good performance and high efficiency.
GPB uses the .proto file to describe a dictionary for encoding, which is the data structure description. You can use a tool such as Protoc to automatically generate code (for example, Java code) based on the .proto file. Then, perform secondary development based on the automatically generated code, thereby implementing device interworking. Table 1 compares GPB encoding and decoding.
GPB Encoding |
GPB Decoding |
---|---|
{ 1:"HUAWEI" 2:"s4" 3:"huawei-ifm:ifm/interfaces/interface" 4:46 5:1515727243419 6:1515727243514 7{ 1[{ 1: 1515727243419 2 { 5{ 1[{ 5:1 16:2 25:"Eth-Trunk1" }] } } }] } 8:1515727243419 9:10000 10:"OK" 11:"NetEngine 8000 F" 12:0 16:"V800R021C00SPC100" } |
{ "node_id_str":"HUAWEI", "subscription_id_str":"s4", "sensor_path":"huawei-ifm:ifm/interfaces/interface", "collection_id":46, "collection_start_time":"2018/1/12 11:20:43.419", "msg_timestamp":"2018/1/12 11:20:43.514", "data_gpb":{ "row":[{ "timestamp":"2018/1/12 11:20:43.419", "content":{ "interfaces":{ "interface":[{ "ifAdminStatus":1, "ifIndex":2, "ifName":"Eth-Trunk1" }] } } }] }, "collection_end_time":"2018/1/12 11:20:43.419", "current_period":10000, "except_desc":"OK", "product_name":"NetEngine 8000 F", "encoding":Encoding_GPB, "software_version":"V800R021C00SPC100" } |
Support for the JavaScript Object Notation (JSON) Encoding Format
JavaScript object notation (JSON) is a lightweight data exchange format. Based on a subset of the ECMAScript (JS specification developed by the ECMA), it uses a text format independent of the programming language to store and express data with a simple and clear structure, so that the data can be easily read or compiled by human and parsed or generated by computers. Table 2 shows the JSON encoding format.
JSON Encoding |
---|
{ "node_id_str":"HUAWEI", "subscription_id_str":"s4", "sensor_path":"huawei-ifm:ifm/interfaces/interface", "collection_id":46, "collection_start_time":"2018/1/12 11:20:43.419", "msg_timestamp":"2018/1/12 11:20:43.514", "collection_end_time":"2018/1/12 11:20:43.419", "current_period":10000, "except_desc":"OK", "product_name":"NetEngine 8000 F", "encoding":Encoding_JSON, "data_str":{ "row":[{ "timestamp":"2018/1/12 11:20:43.419", "content":{ "interfaces":{ "interface":[{ "ifAdminStatus":1, "ifIndex":2, "ifName":"Eth-Trunk1" }] } } }] }, "software_version":"V800R021C00SPC100" } |
For data transmitted between devices and collectors, the data encoded in the GPB format has a higher information load capability than that encoded in other formats (JSON or XML). GPB encoding ensures Telemetry data throughput capabilities and reduces the CPU usage and bandwidth.
If telemetry uses the JSON encoding format, the data packets sent to the collector do not contain the typesetting characters such as carriage return or space to reduce the size of JSON encoding data.