Data forwarding processing method, device, gateway device and storage medium

CN116033296BActive Publication Date: 2025-09-05XIAMEN FOUR-FAITH SMART POWER TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211638937.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-20
Publication Date
2025-09-05
Estimated Expiration
2042-12-20

AI Technical Summary

Technical Problem

[0003]目前,在对数据进行转发时一般采用数据库来实现,但不管是多线程还是多进程访问数据库都需要加锁,且数据库内部处理所需的代码量大,需要更多的flash代码空间和内存空间,如此导致网关的整体成本增高

Benefits of technology

[0025] To sum up, this embodiment, through the above-mentioned design method, can, on the one hand, reduce the encryption and unlocking operations under multi-threaded work, thereby improving the efficiency of data processing; on the other hand, by unifying multiple protocols into 7 data types, data is simply exchanged without complex relationships, which facilitates data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116033296B_ABST
    Figure CN116033296B_ABST
Patent Text Reader

Abstract

The present invention discloses a data forwarding processing method, device, gateway device and storage medium. The method includes: receiving collected data sent by each downstream node through a downstream protocol thread and storing it in the downstream protocol locally; pre-processing the collected data according to a pre-configured forwarding relationship table and generating a forwarding table; wherein, during pre-processing, the collected data is sorted in order according to the size of the node number, data type and source node address; the collected data stored in the downstream protocol locally is read by the upstream protocol thread according to the forwarding table and stored in the upstream protocol locally; wherein, during copying, the collected data of the same downstream protocol thread is uniformly encrypted and unlocked; and the upstream protocol thread sends the collected data to the upstream node. The present invention occupies less storage space on the gateway device, has low CPU overhead and low hardware requirements, thereby effectively reducing the hardware cost of the gateway device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a data forwarding processing method, device, gateway equipment and storage medium. Background Art

[0002] With the rapid development of remote meter reading in distribution rooms, the amount of data that the gateway, as a transit gateway, needs to forward is increasing. Therefore, the design requirements for the gateway's hardware performance and program forwarding solutions are also becoming higher and higher. How to realize the gateway's big data forwarding with a low-cost solution has become a difficult problem that needs to be solved urgently.

[0003] Currently, databases are generally used to forward data. However, whether it is multi-threaded or multi-process access to the database, locking is required, and the amount of code required for internal database processing is large, requiring more flash code space and memory space, which increases the overall cost of the gateway. Summary of the Invention

[0004] The embodiments of the present invention provide a data forwarding processing method, apparatus, gateway device and storage medium to improve the above-mentioned problem.

[0005] An embodiment of the present invention provides a data forwarding processing method, which includes:

[0006] Receive the collected data sent by each downstream node through the downstream protocol thread and store it in the downstream protocol local; wherein each downstream protocol thread corresponds to a downstream node, and the collected data includes the source node number, data type, source node address, destination node number, and destination node address;

[0007] According to a pre-configured forwarding relationship table, the collected data is pre-processed and a forwarding table is generated; wherein, during the pre-processing, the collected data is sorted in order according to the node number, data type, and source node address;

[0008] The uplink protocol thread reads the collected data stored in the downlink protocol locally according to the forwarding table and saves it in the uplink protocol locally; wherein, when copying, the collected data of the same downlink protocol thread is uniformly encrypted and unlocked;

[0009] The collected data is sent to the upstream node by the upstream protocol thread.

[0010] Preferably, the data types include remote signaling, remote measurement, remote pulse, fixed value reading, remote control, remote adjustment, and fixed value writing.

[0011] Preferably, each upstream node and downstream node corresponds to a thread, and each thread is allocated to exchange global variables of seven data types.

[0012] Preferably, it also includes:

[0013] When reading, data is exchanged using an exchange method corresponding to the data type of the collected data.

[0014] Preferably, for remote signaling, remote measurement, remote pulse, and fixed value reading types of data, multi-threaded locked direct memory copy is used for data exchange during reading;

[0015] For remote control, remote adjustment, and fixed value writing types of data, queue transmission is used for data exchange during reading.

[0016] An embodiment of the present invention further provides a data forwarding processing device, which includes:

[0017] The collection unit is used to receive the collected data sent by each downstream node through the downstream protocol thread and store it in the downstream protocol local; wherein each downstream protocol thread corresponds to a downstream node, and the collected data includes the source node number, data type, source node address, destination node number, and destination node address;

[0018] A preprocessing unit, configured to preprocess the collected data according to a preconfigured forwarding relationship table and generate a forwarding table; wherein, during the preprocessing, the collected data is sorted in order of node number, data type, and source node address;

[0019] A reading unit, configured to read the collected data stored in the local downlink protocol according to the forwarding table by the uplink protocol thread and save the data in the local uplink protocol; wherein, when copying, the collected data of the same downlink protocol thread is uniformly encrypted and unlocked;

[0020] The sending unit is configured to send the collected data to the uplink node via the uplink protocol thread.

[0021] Preferably, the data types include remote signaling, remote measurement, remote pulse, fixed value reading, remote control, remote adjustment, and fixed value writing.

[0022] Preferably, each upstream node and downstream node corresponds to a thread, and each thread is allocated to exchange global variables of seven data types.

[0023] An embodiment of the present invention further provides a gateway device, which includes a computer-readable storage medium and a processor, wherein the computer-readable storage medium stores a computer program, and the computer program can be executed by the processor to implement the data forwarding processing method as described above.

[0024] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program. The computer program can be executed by a processor of a device where the computer-readable storage medium is located to implement the above-mentioned data forwarding processing method.

[0025] To sum up, this embodiment, through the above-mentioned design method, can, on the one hand, reduce the encryption and unlocking operations under multi-threaded work, thereby improving the efficiency of data processing; on the other hand, by unifying multiple protocols into 7 data types, data is simply exchanged without complex relationships, which facilitates data transmission.

[0026] Thus, compared with the database solution, this embodiment occupies less storage space on the gateway device, has less CPU overhead, and has lower hardware requirements when forwarding data, thereby effectively reducing the hardware cost of the gateway device. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the technical solution of the present invention, the following is a brief introduction to the drawings required for use in the implementation. Obviously, the drawings described below are only some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0028] Figure 1 It is a flowchart of the data forwarding processing method provided by the first embodiment of the present invention.

[0029] Figure 2 It is a schematic diagram of a forwarding relationship table provided by an embodiment of the present invention.

[0030] Figure 3 It is a structural diagram of a data forwarding processing device provided by the second embodiment of the present invention. DETAILED DESCRIPTION

[0031] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0032] See also Figure 1 The first embodiment of the present invention provides a data forwarding processing method, which can be executed by a gateway device to implement the following steps:

[0033] S101, receiving the collected data sent by each downstream node through the downstream protocol thread and storing it in the downstream protocol local; wherein each downstream protocol thread corresponds to a downstream node, and the collected data includes the source node number, data type, source node address, destination node number, and destination node address.

[0034] In this embodiment, the gateway device is used to achieve network interconnection above the network layer. A gateway can be used for both wide area network (WAN) and local area network (LAN) interconnection. It is a computer system or device that performs conversion tasks, typically between systems with different communication protocols, data formats or languages, or even completely different architectures.

[0035] In the field of Internet of Things, gateway devices generally serve as conversion devices between upstream nodes and downstream nodes. They can send data collected by downstream nodes, such as various sensors, electricity meters and other collection devices, to upstream nodes. They can also send control instructions generated by upstream nodes to downstream nodes, thereby realizing the control and feedback of upstream nodes to downstream nodes.

[0036] In this embodiment, the gateway device is a device based on the LINUX system, wherein a predetermined application program may be installed in the gateway device, and its processor may implement all the functions of this embodiment by executing the application program.

[0037] In this embodiment, specifically, for each downstream node, the gateway device generates a corresponding downstream protocol thread to obtain the collected data of the downstream node. Similarly, for each upstream node, the gateway device generates a corresponding upstream protocol thread to realize data exchange with the upstream node.

[0038] In this embodiment, generally, the collected data includes a source node number, a data type, a source node address, a destination node number, and a destination node address.

[0039] The source node number represents the serial number of the source node from which the data is collected, the source node address represents the address of the source node, the destination node number represents the serial number of the destination node, and the destination node address represents the address of the destination node.

[0040] In one embodiment, in order to achieve better management of collected data, the data types of collected data are divided into the following seven categories:

[0041] (1) Collection: remote signaling, remote measurement, remote pulse, and fixed value reading;

[0042] (2) Control: remote control, remote adjustment, and fixed value writing.

[0043] S102, pre-processing the collected data according to a pre-configured forwarding relationship table and generating a forwarding table; wherein, during the pre-processing, the collected data is sorted in order according to the source node number, data type, and size of the source node address.

[0044] In this embodiment, a forwarding relationship table can be generated by a configuration tool and stored in the gateway device. The tool can pre-process and map all collected data according to pre-configured processing rules to generate a forwarding table. During pre-processing, the collected data is sorted by source node number, data type, and source node address. During mapping, the mapping fields corresponding to the source node number, data type, source node address, destination node number, and destination node address are replaced to ultimately generate a forwarding table.

[0045] Among them, the configuration tool (such as a PC computer) generates the following after preprocessing: Figure 2 The forwarding relationship table shown is transmitted to the gateway device through a custom protocol and stored in flash memory. It is sent in the form of key value and content. The content is separated by spaces in each row and commas in each column. For example, the remote signal forwarding table yxtable = 0,0,0,0,0,0,0,0,0 (space) 0,0,1,1,0,0,0,0,0,0..............

[0046] In addition, the configuration tool also sets how to exchange 7 types of data, specifically:

[0047] For remote signaling, remote measurement, remote pulse, and fixed value reading, the exchange is carried out by locking direct memory copy under multi-threading

[0048] For remote control, remote adjustment and fixed value writing, queue transmission is used for exchange.

[0049] In this embodiment, the reason for pre-generating the forwarding relationship table on the configuration tool is that if it is not pre-sorted on the configuration tool, it must either be sorted before each gateway program is loaded, or sorted on the gateway side when the configuration is issued. This implementation is time-consuming and complicated, which is not conducive to reducing the cost of gateway equipment.

[0050] S103, the uplink protocol thread reads the collected data stored in the downlink protocol local according to the forwarding table and saves it in the uplink protocol local; wherein, during the reading, the collected data of the same downlink protocol thread are uniformly encrypted and unlocked.

[0051] Among them, since this embodiment is implemented in multi-threading under the Linux system, each upstream and downstream protocol node uses a thread, and each thread is allocated to exchange 7 types of data global variables. According to the requirements of the Linux system, access to global variables under multi-threading requires locking, which will cause frequent locking and unlocking operations, resulting in reduced processing efficiency.

[0052] To this end, in this embodiment, when reading, the upstream protocol thread will perform unified encryption and unlocking processing on the collected data of the same downstream protocol thread according to the forwarding table, thereby reducing the number of encryption and unlocking operations and improving the efficiency of data forwarding.

[0053] S104: The uplink protocol thread sends the collected data to the uplink node.

[0054] To facilitate understanding of the present invention, a specific example will be used below to illustrate the application of the present invention.

[0055] Specifically, assume that there are three downlink nodes, namely the downlink system node, downlink node WD1, and downlink node WD2, and the collected data sent by them and in the order are as follows:

[0056] Downstream system node-cpu usage (copied to)mqtt-telemetry1

[0057] Downstream node WD1-(NDB5E)U(copy to)mqtt-telemetry3

[0058] Downstream node WD2-(NDB5E)I (copy to)mqtt-telemetry4

[0059] Downstream node WD2-(NDB5E)U (copy to)mqtt-telemetry5

[0060] Downstream system node - memory usage (copied to) mqtt-telemetry 6

[0061] Downstream node WD1-(NDB5E)HZ (copied to)mqtt-telemetry7

[0062] Downstream node WD1-(NDB5E)TP(copy to)mqtt-telemetry8

[0063] Downstream node WD2-(NDB5E)HZ (copied to)mqtt-telemetry9

[0064] Downstream node WD2-(NDB5E)TP(copy to)mqtt-telemetry10

[0065] At this time, under normal circumstances, in order to realize the forwarding of these data, six encryption and unlocking operations are required: (1)

[0067] Lock downlink system node data

[0068] Downstream system node-cpu usage (copied to)mqtt-telemetry1

[0069] Unlock downlink system node data (2)

[0071] Lock the downstream node WD1 data

[0072] Downstream node WD1-(NDB5E)I (copy to)mqtt-telemetry2

[0073] Downstream node WD1-(NDB5E)U(copy to)mqtt-telemetry3

[0074] Unlock downstream node WD1 data (3)

[0076] Lock the downstream node WD2 data

[0077] Downstream node WD2-(NDB5E)I (copy to)mqtt-telemetry4

[0078] Downstream node WD2-(NDB5E)U (copy to)mqtt-telemetry5

[0079] Unlock downstream node WD2 data (4)

[0081] Lock downlink system node data

[0082] Downstream system node - memory usage (copied to) mqtt-telemetry 6

[0083] Unlock downlink system node data (5)

[0085] Lock the downstream node WD1 data

[0086] Downstream node WD1-(NDB5E)HZ (copied to)mqtt-telemetry7

[0087] Downstream node WD1-(NDB5E)TP(copy to)mqtt-telemetry8

[0088] Unlock downstream node WD1 data (6)

[0090] Lock the downstream node WD2 data

[0091] Downstream node WD2-(NDB5E)HZ (copied to)mqtt-telemetry9

[0092] Downstream node WD2-(NDB5E)TP(copy to)mqtt-telemetry10

[0093] Unlock downstream node WD2 data

[0094] In this embodiment, after receiving the collected data, the collected data will be sorted in order according to the source node number, data type, and source node address. The sorting results are as follows:

[0095] Downstream system node-cpu usage (copied to)mqtt-telemetry1

[0096] Downstream system node - memory usage (copied to) mqtt-telemetry 6

[0097] Downstream node WD1-(NDB5E)I (copy to)mqtt-telemetry2

[0098] Downstream node WD1-(NDB5E)U(copy to)mqtt-telemetry3

[0099] Downstream node WD1-(NDB5E)HZ (copied to)mqtt-telemetry7

[0100] Downstream node WD1-(NDB5E)TP(copy to)mqtt-telemetry8

[0101] Downstream node WD2-(NDB5E)I (copy to)mqtt-telemetry4

[0102] Downstream node WD2-(NDB5E)U (copy to)mqtt-telemetry5

[0103] Downstream node WD2-(NDB5E)HZ (copied to)mqtt-telemetry9

[0104] Downstream node WD2-(NDB5E)TP(copy to)mqtt-telemetry10

[0105] Then, map the fields to get the following forwarding table:

[0106] Source node number Data Type Source node address Destination node number Destination node address 0 1 1 3 1 1 1 1 3 2 1 1 2 3 3 1 1 3 3 7 2 1 1 3 4 2 1 2 3 5 2 1 3 3 9 2 1 4 3 10

[0107] The source node number is 0, which represents the downstream system node, 1, which represents the downstream node WD1, and 2, which represents the downstream node WD2.

[0108] Data type 1 indicates a telemetry signal.

[0109] Destination node number 3 represents mqtt.

[0110] Therefore, after obtaining the forwarding table, the upstream protocol thread copies the process according to the forwarding table as follows: (1)

[0112] Lock downlink system node data

[0113] Downstream system node-cpu usage (copied to)mqtt-telemetry1

[0114] Downstream system node - memory usage (copied to) mqtt-telemetry 6

[0115] Unlock downlink system node data (2)

[0117] Lock the downstream node WD1 data

[0118] Downstream node WD1-(NDB5E)I (copy to)mqtt-telemetry2

[0119] Downstream node WD1-(NDB5E)U(copy to)mqtt-telemetry3

[0120] Downstream node WD1-(NDB5E)HZ (copied to)mqtt-telemetry7

[0121] Downstream node WD1-(NDB5E)TP(copy to)mqtt-telemetry8

[0122] Unlock downstream node WD1 data (3)

[0124] Lock the downstream node WD2 data

[0125] Downstream node WD2-(NDB5E)I (copy to)mqtt-telemetry4

[0126] Downstream node WD2-(NDB5E)U (copy to)mqtt-telemetry5

[0127] Downstream node WD2-(NDB5E)HZ (copied to)mqtt-telemetry9

[0128] Downstream node WD2-(NDB5E)TP(copy to)mqtt-telemetry10

[0129] Unlock downstream node WD2 data

[0130] As you can see, only three unlocking and unlocking operations are required, which improves data processing efficiency.

[0131] To sum up, this embodiment, through the above-mentioned design method, can, on the one hand, reduce the encryption and unlocking operations under multi-threaded work, thereby improving the efficiency of data processing; on the other hand, by unifying multiple protocols into 7 data types, data is simply exchanged without complex relationships, which facilitates data transmission.

[0132] Thus, compared with the database solution, this embodiment occupies less storage space on the gateway device, has less CPU overhead, and has lower hardware requirements when forwarding data, thereby effectively reducing the hardware cost of the gateway device.

[0133] See also Figure 3 The second embodiment of the present invention further provides a data forwarding processing device, which includes:

[0134] The collection unit 210 is used to receive the collected data sent by each downstream node through the downstream protocol thread and store it in the downstream protocol local; wherein each downstream protocol thread corresponds to a downstream node, and the collected data includes the source node number, data type, source node address, destination node number, and destination node address;

[0135] The preprocessing unit 220 is used to preprocess the collected data according to the pre-configured forwarding relationship table and generate a forwarding table; wherein, during the preprocessing, the collected data is sorted in order according to the node number, data type, and source node address;

[0136] The reading unit 230 is configured to read the collected data stored in the local downlink protocol according to the forwarding table by the uplink protocol thread and store it in the local uplink protocol; wherein, when copying, the collected data of the same downlink protocol thread is uniformly encrypted and unlocked;

[0137] The sending unit 240 is configured to send the collected data to an upstream node via an upstream protocol thread.

[0138] Preferably, the data types include remote signaling, remote measurement, remote pulse, fixed value reading, remote control, remote adjustment, and fixed value writing.

[0139] Preferably, each upstream node and downstream node corresponds to a thread, and each thread is allocated to exchange global variables of seven data types.

[0140] The third embodiment of the present invention further provides a gateway device, which includes a computer-readable storage medium and a processor, wherein the computer-readable storage medium stores a computer program, and the computer program can be executed by the processor to implement the data forwarding processing method as described above.

[0141] The fourth embodiment of the present invention further provides a computer-readable storage medium storing a computer program, which can be executed by a processor of the device where the computer-readable storage medium is located to implement the data forwarding processing method as described above. The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited to this. Any changes or replacements that can be easily thought of by any technician familiar with this technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A data forwarding processing method, characterized in that: include: The collected data sent by each downstream node is received through the downstream protocol thread and stored in the downstream protocol locally; wherein, each downstream protocol thread corresponds to a downstream node, and the collected data includes the source node number, data type, source node address, destination node number, and destination node address; the data types include remote signaling, remote measurement, remote pulse, fixed value reading, remote control, remote adjustment, and fixed value writing; each upstream node and downstream node corresponds to a thread, and each thread is allocated to exchange global variables of 7 data types; when reading, the exchange method corresponding to the data type of the collected data is used to exchange data; for remote signaling, remote measurement, remote pulse, and fixed value reading type data, multi-threaded locked direct memory copy is used for data exchange when reading; for remote control, remote adjustment, and fixed value writing type data, queue transmission is used for data exchange when reading; According to a pre-configured forwarding relationship table, the collected data is pre-processed and a forwarding table is generated; wherein, during the pre-processing, the collected data is sorted in order according to the node number, data type, and source node address; The uplink protocol thread reads the collected data stored in the downlink protocol locally according to the forwarding table and saves it in the uplink protocol locally; wherein, when copying, the collected data of the same downlink protocol thread is uniformly encrypted and unlocked; The collected data is sent to the upstream node by the upstream protocol thread.

2. A data forwarding processing device, characterized in that: include: The acquisition unit is used to receive the collected data sent by each downstream node through the downstream protocol thread and store it in the downstream protocol locally; wherein, each downstream protocol thread corresponds to a downstream node, and the collected data includes the source node number, data type, source node address, destination node number, and destination node address; the data types include remote signaling, remote measurement, remote pulse, fixed value reading, remote control, remote adjustment, and fixed value writing; each upstream node and downstream node corresponds to a thread, and each thread is allocated to exchange global variables of 7 data types; when reading, the exchange method corresponding to the data type of the collected data is used to exchange data; for remote signaling, telemetry, remote pulse, and fixed value reading type data, multi-threaded locked direct memory copy is used for data exchange when reading; for remote control, remote adjustment, and fixed value writing type data, queue transmission is used for data exchange when reading; A preprocessing unit, configured to preprocess the collected data according to a preconfigured forwarding relationship table and generate a forwarding table; wherein, during the preprocessing, the collected data is sorted in order of node number, data type, and source node address; A reading unit, configured to read the collected data stored in the local downlink protocol according to the forwarding table by the uplink protocol thread and save the data in the local uplink protocol; wherein, when copying, the collected data of the same downlink protocol thread is uniformly encrypted and unlocked; The sending unit is configured to send the collected data to the uplink node via the uplink protocol thread.

3. A gateway device, characterized in that: The device comprises a computer-readable storage medium and a processor, wherein the computer-readable storage medium stores a computer program, and the computer program can be executed by the processor to implement the data forwarding processing method according to claim 1.

4. A computer-readable storage medium, characterized in that A computer program is stored, and the computer program can be executed by a processor of the device where the computer-readable storage medium is located to implement the data forwarding processing method according to claim 1.

Citation Information

Patent Citations

  • Resources access method, business server, distributed system and storage medium

    CN108319496A