Data transmission method and device, storage medium and electronic device
By determining the target status in the first gateway and sending data information to the third process in the second gateway under abnormal conditions, the problem of long-term switching of the main gateway to the backup gateway is solved, and the effect of seamless switching of the main gateway to the backup gateway is achieved, and the reliability and response speed of the system are improved.
Patent Information
- Application Number
- CN202510224463.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-27
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2045-02-27
AI Technical Summary
In the prior art, switching from the main gateway to the backup gateway takes a long time, resulting in unsmooth system switching.
Seamless transmission of data is achieved by determining the target state in the first gateway and sending data information to the third process in the second gateway under abnormal conditions.
It reduces the time for switching between the master and spare gateways, realizes the effect of seamless switching between the master gateways and the system's reliability and response speed.
Smart Images

Figure CN119728402A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of communications, and in particular, to a data transmission method, device, storage medium and electronic device. Background Art
[0002] In the related technology, two identical gateways are usually used in operation at the same time, one of which is a normal working gateway, collecting data in real time and reporting it to the controller, and the other is in standby mode and does not participate in data collection. When the working gateway fails, the standby gateway enters the working state to complete the switch, but the standby gateway needs to register the device and the gateway for switching to the normal working state, which takes a long time.
[0003] It can be seen from this that there is a technical problem in the related art that it takes a long time for the main gateway to switch to the backup gateway.
[0004] In view of the above problems existing in the related technologies, no effective solutions have been proposed yet. Summary of the invention
[0005] The embodiments of the present invention provide a data transmission method, device, storage medium and electronic device to at least solve the problem in the related art that it takes a long time to switch from a primary gateway to a backup gateway.
[0006] According to an embodiment of the present invention, there is provided a data transmission method, comprising: determining a target state of a first process in a first gateway, wherein the first gateway is connected to a target platform through the first process; sending data information of a device connected to the first gateway to a second process in the first gateway when the target state indicates that the first process is in an abnormal state; controlling the second process to send the data information to a third process to instruct the third process to send the data information to the target platform, wherein the third process is a process in the second gateway that allows data transmission with the second process, and the second gateway is connected to the target platform through the third process.
[0007] In an exemplary embodiment, before controlling the second process to send the data information to the third process, the method further includes: determining a load status of a third gateway that establishes a backup candidate relationship with the first gateway; determining a fourth gateway that meets a predetermined condition from the third gateways based on the load status; and, when there are multiple fourth gateways, sorting the fourth gateways to obtain a target sorting result, and determining the second gateway from the fourth gateways based on the target sorting result.
[0008] In an exemplary embodiment, determining the load status of a third gateway that establishes a backup candidate relationship with the first gateway includes: acquiring target information according to a predetermined time period, wherein the target information includes at least one of the following: a processor utilization rate of the third gateway, a memory utilization rate of the third gateway, a number of backup gateways allowed to serve as backup gateways of the third gateway, a network signal strength of the third gateway, a number of sub-devices of the third gateway, and a number of historical failures of the third gateway; and determining the acquired target information as the load status.
[0009] In an exemplary embodiment, determining the fourth gateway that meets the predetermined condition from the third gateways based on the load status includes: determining a processor utilization rate included in the load status, and determining a gateway included in the third gateways whose processor utilization rate is less than a first preset threshold as a fifth gateway; determining a memory usage rate of the fifth gateway included in the load status, and determining a gateway whose memory usage rate is less than a second preset threshold as a sixth gateway; determining the number of backup gateways allowed to serve as backup gateways of the sixth gateway included in the load status, and determining a gateway whose number of backup gateways is greater than a third preset threshold as a seventh gateway; and determining a network signal strength of the seventh gateway included in the load status, and determining a gateway whose network signal strength is greater than a fourth preset threshold as the fourth gateway.
[0010] In an exemplary embodiment, sorting the fourth gateway to obtain a target sorting result includes: determining the number of sub-devices of the fourth gateway included in the load status, sorting the fourth gateway according to the number of sub-devices, and obtaining an initial sorting; determining the number of historical failures of the fourth gateway included in the load status, adjusting the initial sorting according to the number of historical failures, and obtaining the target sorting result.
[0011] In an exemplary embodiment, after controlling the second process to send the data information to the third process, the method further includes: receiving feedback data sent by the second gateway, wherein the feedback data is data obtained by the target platform processing the data information; and storing the feedback data.
[0012] In an exemplary embodiment, after storing the feedback data, the method further includes: when the target state changes from the abnormal state to the normal state, controlling the second process to send the feedback data to the first process.
[0013] According to another embodiment of the present invention, there is provided a data transmission device, comprising: a determination module, configured to determine a target state of a first process in a first gateway, wherein the first gateway is connected to a target platform through the first process; a first sending module, configured to send data information of a device connected to the first gateway to a second process in the first gateway when the target state indicates that the first process is in an abnormal state; and a second sending module, configured to control the second process to send the data information to a third process to instruct the third process to send the data information to the target platform, wherein the third process is a process in the second gateway that allows data transmission with the second process, and the second gateway is connected to the target platform through the third process.
[0014] According to yet another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any one of the above method embodiments when run.
[0015] According to yet another embodiment of the present invention, there is provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0016] According to yet another embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of the method described in each embodiment of the present application are implemented.
[0017] Through the present invention, the target state of the first process in the first gateway connected to the target platform can be determined. When the target state indicates that the first process is in an abnormal state, the data information of the device connected to the first gateway can be sent to the second process of the first gateway, and the second process can be controlled to send the data information to the third process in the second gateway, indicating the third process to send the data information to the target platform. Since the first gateway and the second gateway can both work normally independently, when the first gateway is in an abnormal state, the second gateway can directly replace the first gateway to transmit data, that is, the data information of the device connected to the first gateway can be sent to the same target platform through the third process in the second gateway that has established a data transmission relationship with the first gateway, and there is no need to re-establish a data transmission relationship with the device connected to the first gateway, thereby reducing the switching time. Therefore, the problem of the long time required for the main gateway to switch to the backup gateway in the related art can be solved, and the time required for switching between the main and backup gateways can be shortened, thereby achieving the effect of seamlessly switching the main gateway to the backup gateway. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 A hardware structure frame of a mobile terminal according to a data transmission method of an embodiment of the present invention;
[0019] Figure 2 is a flow chart of a data transmission method according to an embodiment of the present invention;
[0020] Figure 3 is a schematic diagram of a gateway backup system according to an embodiment of the present invention;
[0021] Figure 4 is a schematic diagram of data transmission relationship between processes when a main process is abnormal according to an embodiment of the present invention;
[0022] Figure 5 is a schematic diagram of a gateway group according to an embodiment of the present invention;
[0023] Figure 6 is a flow chart of a gateway backup load balancing solution according to an embodiment of the present invention;
[0024] Figure 7 is a schematic diagram of the transmission relationship of data between processes when the main process is normal according to an embodiment of the present invention;
[0025] Figure 8 is a flow chart of a data transmission method according to a specific embodiment of the present invention;
[0026] Fig. 9 is a structural block diagram of a data transmission device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0027] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings and in combination with the embodiments.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0029] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of a data transmission method according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0030] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the data transmission method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the mobile terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0031] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0032] In this embodiment, a data transmission method is provided. Figure 2 is a flow chart of a data transmission method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0033] Step S202, determining a target state of a first process in a first gateway, wherein the first gateway is connected to a target platform through the first process;
[0034] Step S204, when the target state indicates that the first process is in an abnormal state, sending data information of a device connected to the first gateway to a second process in the first gateway;
[0035] Step S206, controlling the second process to send the data information to the third process to instruct the third process to send the data information to the target platform, wherein the third process is a process in the second gateway that allows data transmission with the second process, and the second gateway is connected to the target platform through the third process.
[0036] In the above embodiment, the gateway can be understood as a link between the perception network and the traditional communication network, which can realize the protocol conversion between the perception network and the communication network, and between different types of perception networks, and can also realize wide area interconnection and local area interconnection. Figure 3 , Figure 3 Schematic diagram of a gateway backup system according to an embodiment of the present invention. Figure 3 As shown, the first gateway can be the main gateway A, and the second gateway can be the backup gateway B. Both the first gateway and the second gateway need to include a daemon process, a main process, an auxiliary process, and an access process. The access process also needs to transmit data with multiple sub-devices and can receive data sent from multiple sub-devices. The first gateway and the second gateway are gateways that can independently complete data transmission with the target platform under normal working conditions, and both have redundant backup functions. Among them, a process can be understood as the execution process of a program.
[0037] In the related art, each main gateway needs to be set up with a backup gateway, and the backup gateway is enabled when the main gateway fails. For example, when the number of main gateways is 1,000, 1,000 backup gateways are required, that is, 2,000 gateways need to be set up. In this embodiment, the first gateway and the second gateway can be parallel gateways, and both the first gateway and the second gateway can be used as independent gateways to connect different sub-devices and send data from different sub-devices to the target platform. That is, only 1,000 gateways need to be set up, and the gateways included in the 1,000 gateways can back up each other, without the need to set up dedicated backup gateways. By adding a backup function to the working gateway, the number of backup gateways can be reduced by half, and 1,000 additional backup gateways are not needed. Only 1,000 gateways are needed to achieve seamless switching of the main and backup gateways, and the cost of using the equipment can be greatly reduced.
[0038] In the above embodiment, the main process can be responsible for most of the tasks in the gateway, such as connecting with the target platform, scheduled tasks, or adding, deleting, modifying, and checking sub-devices with which data transmission relationships are established, but not limited thereto. The auxiliary process can be responsible for connecting with other gateways, and the two gateways that have established connections can serve as backup gateways for each other. When the main process of one of the gateways is abnormal, the service can be quickly sent to the backup gateway. The access process can be responsible for the access of multiple sub-devices, and can establish data transmission relationships with the main process and the auxiliary process in a multi-process manner to transmit messages and data. The daemon process can be responsible for detecting other processes, and can quickly restart the process when other processes are abnormal.
[0039] In the above embodiment, when the first gateway and the second gateway are in normal working state, the main process in the first gateway (i.e., the above-mentioned first process) can be connected to the cloud platform (i.e., the above-mentioned target platform), and the access process can establish a data transmission relationship between multiple processes with the main process and the auxiliary process, and can also establish a data transmission relationship with multiple sub-devices, and can send data information in multiple sub-devices to the first process, so as to send the data information to the target platform through the first process. The auxiliary process in the first gateway (i.e., the above-mentioned second process) can establish a data transmission relationship with the main process in the second gateway (i.e., the above-mentioned third process), that is, establish a backup relationship, and can be connected through transmission links such as wifi, 4G / 5G, etc., to avoid the wired network used by the main process, and can avoid the auxiliary process from being paralyzed at the same time when the main process network fails.
[0040] In the above embodiment, when the daemon process in the first gateway determines that the target state of the first process is abnormal, the first process can be restarted. In addition, when the access process in the first gateway detects that the first process is abnormal, the data transmission relationship between the main process, the auxiliary process and the access process will change. Figure 4 FIG. 4 is a schematic diagram of the data transmission relationship between processes when the main process is abnormal according to an embodiment of the present invention. Figure 4 As shown, under normal working conditions, the data transmission state of establishing a primary data transmission relationship with the first process and an auxiliary data transmission relationship with the second process will switch to a data transmission state of establishing an auxiliary data transmission relationship with the first process and a primary data transmission relationship with the second process. Among them, the abnormal state can be a freeze, a memory leak, or a failure to connect to the network with the target platform, etc., but is not limited to this. The process whose data transmission state is the primary connection can be understood as a process that receives data information from the connected device (that is, when the first process is in an abnormal state, the second process can receive data information sent by the access process).
[0041] In the above embodiment, the second gateway can act as an agent for the first gateway to forward messages. After receiving the data information, the second process can send the data information to the main process (i.e., the third process) in the second gateway that has established a data transmission relationship with the first gateway. After receiving the data information, the third process can add the identifier of the first gateway to the data message and forward it to the target platform, so as to forward the data information in the first gateway to the same target platform.
[0042] Through the present invention, the target state of the first process in the first gateway connected to the target platform can be determined. When the target state indicates that the first process is in an abnormal state, the data information of the device connected to the first gateway can be sent to the second process of the first gateway, and the second process can be controlled to send the data information to the third process in the second gateway, indicating the third process to send the data information to the target platform. Since the first gateway and the second gateway can both work normally independently, when the first gateway is in an abnormal state, the second gateway can directly replace the first gateway to transmit data, that is, the data information of the device connected to the first gateway can be sent to the same target platform through the third process in the second gateway that has established a data transmission relationship with the first gateway, and there is no need to re-establish a data transmission relationship with the device connected to the first gateway, thereby reducing the switching time. Therefore, the problem of the long time required for the main gateway to switch to the backup gateway in the related art can be solved, and the time required for switching between the main and backup gateways can be shortened, thereby achieving the effect of seamlessly switching the main gateway to the backup gateway.
[0043] Optionally, the execution subject of the above steps may be a background processor, a server, or a terminal, but is not limited thereto.
[0044] In an exemplary embodiment, before controlling the second process to send the data information to the third process, the method further includes: determining a load status of a third gateway that establishes a backup candidate relationship with the first gateway; determining a fourth gateway that meets a predetermined condition from the third gateways based on the load status; and, when there are multiple fourth gateways, sorting the fourth gateways to obtain a target sorting result, and determining the second gateway from the fourth gateways based on the target sorting result.
[0045] In the above embodiment, after the system is initialized, the load status of multiple third gateways adjacent to the first gateway and establishing a candidate backup relationship can be obtained through the gateway search protocol, user specification, etc., and the fourth gateway that meets the predetermined condition among the multiple third gateways can be determined through the gateway load status. The load capacity of multiple gateways in the fourth gateway is sorted in reverse order to obtain the target sorting result, and the gateway ranked first or second in the target sorting result can be determined as the second gateway, that is, the second gateway can be one or more, and can be determined according to the load status of the actual gateway. Among them, the predetermined condition can be that the load status is less than 70% or 50% of the maximum load capacity, but is not limited to this.
[0046] In an exemplary embodiment, determining the load status of a third gateway that establishes a backup candidate relationship with the first gateway includes: acquiring target information according to a predetermined time period, wherein the target information includes at least one of the following: a processor utilization rate of the third gateway, a memory utilization rate of the third gateway, a number of backup gateways allowed to serve as backup gateways of the third gateway, a network signal strength of the third gateway, a number of sub-devices of the third gateway, and a number of historical failures of the third gateway; and determining the acquired target information as the load status.
[0047] In the above embodiment, the gateways may exchange parameters within a predetermined time period. Figure 5 is a schematic diagram of a gateway group according to an embodiment of the present invention, such as Figure 5 As shown, the multiple third gateways adjacent to the first gateway that establish candidate backup relationships may be gateway B, gateway C, gateway D, and gateway E. The first gateway and the multiple third gateways may communicate the load status of the gateway regularly (i.e., the above-mentioned exchange of target information within a predetermined time period), and the target information for interaction may include the number of sub-devices, gateway processor utilization, gateway memory utilization, signal strength of the connection between gateways, the number of backup gateways allowed to be backup gateways (i.e., the number of gateways allowed to be received minus the number of gateways that have been received), and the number of historical failures (e.g., the number of gateway crashes in the past 24 hours, or the number of gateway crashes in the past 48 hours). The load status may be determined by target information including processor utilization, memory utilization, the number of backup gateways allowed to be backup gateways, network signal strength, number of sub-devices, and number of historical failures to determine the second gateway among the third gateways that can establish a backup relationship with the first gateway. Among them, the predetermined time period may be 1 minute or 5 minutes, and the present invention is not limited to this.
[0048] In an exemplary embodiment, determining the fourth gateway that meets the predetermined condition from the third gateways based on the load status includes: determining a processor utilization rate included in the load status, and determining a gateway included in the third gateways whose processor utilization rate is less than a first preset threshold as a fifth gateway; determining a memory usage rate of the fifth gateway included in the load status, and determining a gateway whose memory usage rate is less than a second preset threshold as a sixth gateway; determining the number of backup gateways allowed to serve as backup gateways of the sixth gateway included in the load status, and determining a gateway whose number of backup gateways is greater than a third preset threshold as a seventh gateway; and determining a network signal strength of the seventh gateway included in the load status, and determining a gateway whose network signal strength is greater than a fourth preset threshold as the fourth gateway.
[0049] In the above embodiment, the flowchart for determining the backup gateway can be found in Figure 6 , Figure 6 is a flow chart of a gateway backup load balancing solution according to an embodiment of the present invention, the process includes:
[0050] S602, interactive gateway backup parameters;
[0051] S604, determining whether the CPU is loaded, if it exceeds a threshold, executing step S616, if it does not exceed the threshold, executing step S606;
[0052] S606, determining whether there is free memory, if it exceeds the threshold, executing step S616, if it does not exceed the threshold, executing step S608;
[0053] S608, determining the number of backup gateways, if the number of backup gateways is full, executing step S616, if the number of backup gateways is not full, executing step S610;
[0054] S610, determining the network signal strength, if it is lower than the threshold, executing step S616, if it is not lower than the threshold, executing step S612;
[0055] S612, backup gateway sorting;
[0056] S614, the gateway backup relationship is uploaded to the cloud platform;
[0057] S616: Do not add to the backup gateway list.
[0058] In the above embodiment, the gateway CPU load (i.e., the processor utilization) in the third gateway can be first determined, and the gateway with a processor utilization less than the first preset threshold is determined as a candidate gateway after the first screening (i.e., the fifth gateway), and the gateway with a processor utilization greater than the first preset threshold is not included in the list of backup gateways, wherein the first preset threshold can be a processor utilization of 70%, or a processor utilization of 75%, but is not limited thereto. After excluding the gateways with higher processor utilization, the free memory of the gateway in the fifth gateway (i.e., the memory usage) can be further determined, and the gateway with a memory utilization less than the second preset threshold in the fifth gateway is determined as a candidate gateway after the second screening (i.e., the sixth gateway), and the gateway with a memory utilization greater than the second preset threshold is not included in the list of backup gateways, wherein the second preset threshold can be 5M memory, or 10M memory, etc. Since the number of sub-devices in the gateway and the need to regularly execute sub-device switches and other services will affect the memory, the second preset threshold can be determined according to actual conditions, and the present invention does not limit this. The number of backup gateways allowed to be used as backup gateways included in the sixth gateway can be determined, and the gateways whose number of backup gateways is greater than 0 (i.e., the third preset threshold) are determined as candidate gateways after the third screening (i.e., the seventh gateway). If the number of backup gateways is equal to 0, it can be said that other backup gateways already exist, and the gateway is not included in the list of backup gateways. The network signal strength of the gateways included in the seventh gateway can also be determined, and the gateway whose network signal strength is greater than the fourth preset threshold is determined as the fourth gateway, and the gateway whose network signal strength is less than the fourth preset threshold is not included in the list of backup gateways, wherein the fourth preset threshold can be set according to different networks, for example: when connected via WIFI, the fourth threshold can be -70dBm, or -65 dBm, etc. When connected via 5G / 4G, the fourth preset threshold can be -60dBm, or -50dBm, etc., and the present invention does not limit this.
[0059] In an exemplary embodiment, sorting the fourth gateway to obtain a target sorting result includes: determining the number of sub-devices of the fourth gateway included in the load status, sorting the fourth gateway according to the number of sub-devices, and obtaining an initial sorting; determining the number of historical failures of the fourth gateway included in the load status, adjusting the initial sorting according to the number of historical failures, and obtaining the target sorting result.
[0060] In the above embodiment, the number of sub-devices connected to the gateway included in the fourth gateway can be determined, and the gateways corresponding to the number of sub-devices can be sorted in reverse order to obtain an initial sort, that is, the fewer sub-devices connected to the gateway, the higher the ranking, and the more sub-devices connected to the gateway, the lower the ranking. The initial sort can also be adjusted by the number of historical failures, that is, every time a historical failure occurs to the gateway included in the fourth gateway within a preset period, the ranking is adjusted back by one place to obtain the final target sorting result. Among them, the preset period can be related to the number of adjusted ranking digits, that is, if a failure occurs within the past hour, the corresponding gateway ranking can be adjusted back by 2 places; if a failure occurs within the past 24 hours, the corresponding gateway ranking can be adjusted back by 1 place, and so on. For example, when the fourth gateway includes gateway B, gateway C, gateway D, and gateway E, and the initial ranking is gateway B, gateway C, gateway D, and gateway E, if gateway B has failed in the past hour, gateway B in the initial ranking will be adjusted back by 2 places, and the target ranking result can be gateway C, gateway D, gateway B, and gateway E; if gateway C has failed in the past 24 hours, the ranking of gateway C can be adjusted back by one place, and the target ranking can be gateway D, gateway C, gateway B, and gateway E. After determining the gateway backup order, if the final target ranking result is gateway B, gateway C, gateway D, and gateway E, gateway A can select gateway B as the first backup gateway and gateway C as the second backup gateway. After obtaining the gateway backup relationship, the cloud platform can record it and support processing gateway A messages in the messages reported by gateway D and gateway C.
[0061] In an exemplary embodiment, after controlling the second process to send the data information to the third process, the method further includes: receiving feedback data sent by the second gateway, wherein the feedback data is data obtained by the target platform processing the data information; and storing the feedback data.
[0062] In the above embodiment, at the target platform level, the target platform can select the first gateway and the second gateway to establish a backup relationship on the target platform. When the first gateway fails, the data information of the first gateway can be uploaded to the target platform through the third process in the second gateway. After receiving the data information about the first gateway reported by the third process, the target platform can set the first gateway to an offline state, and can send the feedback data that needs to be sent to the first gateway to the second gateway. The third process in the second gateway can send the feedback data to the second process in the first gateway, and the second process can use the queue to cache the feedback data. The target platform can also choose to continue to send feedback data to the first gateway. Since the first gateway cannot accept the message of the target platform at this time, the feedback data sent by the target platform to the first gateway will be lost.
[0063] In the above embodiment, the target platform can also choose not to establish a backup relationship between the first gateway and the second gateway on the target platform, and only parse and process other gateway messages reported by a certain gateway. For example, in the data message reported by gateway B, the target platform parses the data message and identifies the message of gateway A. It can be determined that the data message is from gateway A, and then the data message of gateway A is processed. However, since the backup relationship is not established, the feedback data of the target platform will not be sent to the second gateway, and the first gateway will not receive the feedback message.
[0064] In an exemplary embodiment, after storing the feedback data, the method further includes: when the target state changes from the abnormal state to the normal state, controlling the second process to send the feedback data to the first process.
[0065] In the above embodiment, when the first process is restarted, it can re-establish the connection with the target platform and re-establish the data transmission relationship with the access process. The data transmission relationship between the main process, the auxiliary process and the access process will be restored to the data transmission relationship under normal working conditions. Figure 7 is a schematic diagram of the transmission relationship of data between processes when the main process is normal according to an embodiment of the present invention, such as Figure 7 As shown, the access process sets the data transmission relationship with the first process as the primary data transmission relationship, and the data transmission relationship with the second process as the secondary data transmission relationship. When the second process detects that the first process has resumed normal operation, it can actively establish a data transmission relationship with the first process, and send the cached feedback data to the first process for processing by the first gateway. At the same time, the second process can notify the third process in the second gateway that the first gateway has resumed normal operation.
[0066] The data transmission method is described below in conjunction with a specific implementation method:
[0067] Figure 8 is a flow chart of a data transmission method according to a specific embodiment of the present invention. Figure 8 As shown, the process includes:
[0068] S802, system initialization;
[0069] S804, the gateway establishes a backup relationship;
[0070] S806, the main process of gateway A is abnormal;
[0071] S808, gateway A switches the connection to gateway B;
[0072] S810, gateway B acts as a proxy for gateway A;
[0073] S812, the main process of gateway A returns to normal.
[0074] In the above embodiment, by establishing a backup candidate relationship between multiple gateways, a backup gateway that establishes a backup relationship with the main gateway can be selected, and the business of the faulty gateway can be transferred to the backup gateway with the lowest load to reduce the impact on the entire system. In addition, through multi-process technology, the main gateway can establish a data transmission relationship with the main process of the backup gateway through the auxiliary process, which increases the gateway backup function. The backup gateway can also establish a backup relationship with the main gateway through the same solution. In scenarios where multiple gateways are required, such as the industrial Internet or smart home, the gateways can form a backup relationship with each other, and no special redundant backup gateway is required. It is also possible to strip the basic functions that are not prone to errors to the access process and the auxiliary process, that is, by establishing a backup data transmission relationship between the two gateways, the main gateway can have two communication links to the platform (the main gateway communication link and the backup gateway communication link). When the main process of the main gateway fails, that is, the main gateway communication link fails, through the detection mechanism between processes, the main gateway can immediately switch to the backup gateway communication link, which can avoid the process of re-entering the network of the sub-device and the gateway reconnecting to the platform.
[0075] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0076] In the present embodiment, a data transmission device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0077] Fig. 9 is a structural block diagram of a data transmission device according to an embodiment of the present invention. Fig. 9 As shown, the device comprises:
[0078] A determination module 92, configured to determine a target state of a first process in a first gateway, wherein the first gateway is connected to a target platform through the first process;
[0079] A first sending module 94, configured to send data information of a device connected to the first gateway to a second process in the first gateway when the target state indicates that the first process is in an abnormal state;
[0080] The second sending module 96 is used to control the second process to send the data information to the third process to instruct the third process to send the data information to the target platform, wherein the third process is a process in the second gateway that allows data transmission with the second process, and the second gateway is connected to the target platform through the third process.
[0081] In an exemplary embodiment, the device can be used to, before controlling the second process to send the data information to the third process: determine the load status of a third gateway that establishes a backup candidate relationship with the first gateway; determine a fourth gateway that meets a predetermined condition from the third gateways based on the load status; and, when there are multiple fourth gateways, sort the fourth gateways to obtain a target sorting result, and determine the second gateway from the fourth gateways based on the target sorting result.
[0082] In an exemplary embodiment, the device can determine the load status of the third gateway that establishes a backup candidate relationship with the first gateway in the following manner: acquiring target information according to a predetermined time period, wherein the target information includes at least one of the following: a processor utilization rate of the third gateway, a memory usage rate of the third gateway, a number of backup gateways allowed to serve as backup gateways of the third gateway, a network signal strength of the third gateway, a number of sub-devices of the third gateway, and a number of historical failures of the third gateway; and determining the acquired target information as the load status.
[0083] In an exemplary embodiment, the device may also determine the fourth gateway that meets the predetermined condition from the third gateways based on the load state in the following manner: determine the processor utilization included in the load state, and determine the gateway included in the third gateway whose processor utilization is less than a first preset threshold as the fifth gateway; determine the memory usage of the fifth gateway included in the load state, and determine the gateway whose memory usage is less than a second preset threshold as the sixth gateway; determine the number of backup gateways allowed to serve as backup gateways of the sixth gateway included in the load state, and determine the gateway whose number of backup gateways is greater than the third preset threshold as the seventh gateway; determine the network signal strength of the seventh gateway included in the load state, and determine the gateway whose network signal strength is greater than a fourth preset threshold as the fourth gateway.
[0084] In an exemplary embodiment, the device can also sort the fourth gateway to obtain a target sorting result in the following manner: determine the number of sub-devices of the fourth gateway included in the load status, sort the fourth gateway according to the number of sub-devices, and obtain an initial sorting; determine the number of historical failures of the fourth gateway included in the load status, adjust the initial sorting according to the number of historical failures, and obtain the target sorting result.
[0085] In an exemplary embodiment, the device can also be used to, after controlling the second process to send the data information to the third process: receive feedback data sent by the second gateway, wherein the feedback data is data obtained by the target platform processing the data information; and store the feedback data.
[0086] In an exemplary embodiment, after storing the feedback data, the apparatus may also be configured to: when the target state changes from the abnormal state to the normal state, control the second process to send the feedback data to the first process.
[0087] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.
[0088] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.
[0089] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0090] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0091] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0092] An embodiment of the present invention further provides a computer program product, including a computer program, which implements the steps of the method in each embodiment of the present application when the computer program is executed by a processor.
[0093] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.
[0094] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0095] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A data transmission method, characterized in that: include: Determining a target state of a first process in a first gateway, wherein the first gateway is connected to a target platform through the first process; When the target state indicates that the first process is in an abnormal state, sending data information of a device connected to the first gateway to a second process in the first gateway; Control the second process to send the data information to the third process to instruct the third process to send the data information to the target platform, wherein the third process is a process in the second gateway that allows data transmission with the second process, and the second gateway is connected to the target platform through the third process.
2. The method according to claim 1, characterized in that Before controlling the second process to send the data information to the third process, the method further includes: Determining a load state of a third gateway that establishes a backup candidate relationship with the first gateway; Determine a fourth gateway that meets a predetermined condition from the third gateways based on the load status; In the case that there are multiple fourth gateways, the fourth gateways are sorted to obtain a target sorting result, and the second gateway is determined from the fourth gateways based on the target sorting result.
3. The method according to claim 2, characterized in that Determining a load state of a third gateway that establishes a backup candidate relationship with the first gateway includes: Acquire target information according to a predetermined time period, wherein the target information includes at least one of the following: processor utilization of the third gateway, memory utilization of the third gateway, the number of backup gateways allowed to be backup gateways of the third gateway, network signal strength of the third gateway, the number of sub-devices of the third gateway, and the number of historical failures of the third gateway; The acquired target information is determined as the load state.
4. The method according to claim 2, characterized in that: Determining a fourth gateway that meets a predetermined condition from the third gateways based on the load state includes: Determine a processor utilization rate included in the load state, and determine a gateway included in the third gateway whose processor utilization rate is less than a first preset threshold as a fifth gateway; Determine the memory usage rate of the fifth gateway included in the load state, and determine a gateway whose memory usage rate is less than a second preset threshold as a sixth gateway; Determine the number of backup gateways included in the load state that are allowed to serve as backup gateways for the sixth gateway, and determine a gateway whose number of backup gateways is greater than a third preset threshold as the seventh gateway; The network signal strength of the seventh gateway included in the load status is determined, and a gateway whose network signal strength is greater than a fourth preset threshold is determined as the fourth gateway.
5. The method according to claim 2, characterized in that: Sorting the fourth gateway to obtain a target sorting result includes: Determine the number of sub-devices of the fourth gateway included in the load state, and sort the fourth gateways according to the number of sub-devices to obtain an initial sort; Determine the number of historical failures of the fourth gateway included in the load status, adjust the initial sorting according to the number of historical failures, and obtain the target sorting result.
6. The method according to claim 1, characterized in that After controlling the second process to send the data information to a third process, the method further includes: receiving feedback data sent by the second gateway, wherein the feedback data is data obtained by the target platform processing the data information; The feedback data is stored.
7. The method according to claim 6, characterized in that After storing the feedback data, the method further includes: When the target state is changed from the abnormal state to the normal state, the second process is controlled to send the feedback data to the first process.
8. A data transmission device, characterized in that: include: a determination module, configured to determine a target state of a first process in a first gateway, wherein the first gateway is connected to a target platform through the first process; A first sending module, configured to send data information of a device connected to the first gateway to a second process in the first gateway when the target state indicates that the first process is in an abnormal state; The second sending module is used to control the second process to send the data information to the third process, so as to instruct the third process to send the data information to the target platform, wherein the third process is a process in the second gateway that allows data transmission with the second process, and the second gateway is connected to the target platform through the third process.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 7 when executed.
10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Message forwarding method, equipment and system
CN108206759A
Report forwarding method, device and system
CN108243114A
Method, equipment and system for processing message
CN109672619A
Communication gateway disaster recovery system and method
CN115529220A
Network equipment fault processing method and device, electronic equipment and storage medium
CN117201281A