Data transmission method and apparatus, storage medium, and electronic device
By grouping data packets according to group identifiers and device information in the security system, and using idle devices in the system to send sub-data in a loop, the problem of long data transmission time and task blocking caused by limited server CPU is solved, and more efficient data synchronization is achieved.
Patent Information
- Application Number
- CN202310117277.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-18
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2043-01-18
AI Technical Summary
In security systems, when a server initiates data transmission tasks to multiple devices, the limited CPU of a single server results in a long overall processing time and can block other tasks. Existing technologies have not been able to effectively solve this problem.
After receiving a data packet, the target data is grouped according to the group identifier and device information, and a hash value request is sent to the device that has not received the complete data. Sub-data is sent in a loop until the receiving device confirms that the data is complete. This optimizes the data synchronization process by making use of idle devices in the system to share the data transmission task.
It reduced server load, improved data synchronization efficiency, avoided task blocking, and achieved faster data transmission speeds.
Smart Images

Figure CN116112510B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of communication, in particular to a data sending method and device, storage medium and electronic device. BACKGROUND
[0002] The intelligent security system is an application of the Internet of Things technology in the security field, wherein the Internet of Things is defined as a technology for connecting things with things through a network. The Internet of Things at the present stage mainly connects various sensors and radio frequency devices, collects data through electronic sensing devices of front-end devices, and realizes the monitoring of massive data through data aggregation of transmission networks, thereby realizing the intelligentization of production and life. In the security field, the devices connected include snapshot cameras in road traffic and attendance machines in parks, and are managed by a visual interface of a management platform. In the security system, the central access platform usually needs to manage a large number of sensor devices, and when data needs to be synchronized to the devices, the central server often faces great pressure. Taking the access control device as an example, the access rights of personnel are checked at the device end, and the central server needs to issue personnel information to the device, and then the device needs to store the personnel information in the database. The personnel information includes card data, fingerprint data, and face data. Since the number of personnel in a large park can reach nearly ten thousand, the network packets transmitted can reach gigabytes, and the process can take several minutes. Considering that the number of managed devices can reach thousands, and the CPU of a single server is limited, the overall time consumption is long, and other tasks are blocked. Therefore, it is particularly important to distribute the data transmission tasks initiated by the access platform server to the device end.
[0003] In the related art, a plurality of distributed server nodes and access nodes are set up, and a load balancer is deployed on each access node. The load balancer is responsible for obtaining the states of a plurality of target server nodes, and selecting an idle server in the server nodes to execute the current data distribution business. However, the disadvantage of the distributed system is that when there is no business period, the overall idle rate of the system is too high.
[0004] In the related art, when the server initiates data transmission tasks to a plurality of device ends, the CPU of a single server is limited, resulting in long overall time consumption and blocking of other tasks. SUMMARY
[0005] Embodiments of the present application provide a data sending method and device, storage medium and electronic device to at least solve the problem in the related art that when the server initiates data transmission tasks to a plurality of device ends, the CPU of a single server is limited, resulting in long overall time consumption and blocking of other tasks.
[0006] According to an embodiment of the present application, a data sending method is provided, comprising: in the case that a complete data packet sent by a data sending end is received, determining a group corresponding to target data in the data packet and group information of the group according to a group identifier in the data packet, wherein the group information of the group comprises device information of a plurality of receiving devices for receiving the target data; and sending the target data to other receiving devices according to the group information, wherein the other receiving devices are devices in the plurality of receiving devices which have not received the complete target data.
[0007] In an example embodiment, the sending the target data to the other receiving devices according to the group information comprises: a sending step of sending a first packet sending request to any receiving device in the other receiving devices, wherein the first packet sending request comprises a hash value of the target data; in the case that the any receiving device determines that the target data has not been received according to the hash value, receiving first response information of the any receiving device, wherein the first response information is used to indicate a first sub-data of the target data which is sent to the any receiving device; sending the first sub-data to the any receiving device; and cyclically executing the sending step until second response information is received, wherein the second response information is used to indicate that the any receiving device has received the complete target data.
[0008] In an example embodiment, before the determining the group corresponding to the target data in the data packet and the group information of the group according to the group identifier in the data packet, the method further comprises: receiving a second packet sending request sent by the data sending end, wherein the second packet sending request comprises a hash value of the target data; determining whether the complete target data is received according to the hash value; and in the case that the complete target data is not successfully received, determining to receive the data packet sent by the data sending end.
[0009] In an example embodiment, before the determining the group corresponding to the target data in the data packet and the group information of the group according to the group identifier in the data packet, the method further comprises: a first receiving step of sending third response information to the data sending end in response to the second packet sending request, wherein the third response information is used to indicate that the data sending end is allowed to send a second sub-data of the target data; in the case that the data sending end receives the third response information, receiving the second sub-data sent by the data sending end; and cyclically executing the first receiving step until the complete target data is received.
[0010] In one example embodiment, the number of data sending ends is multiple, and before determining the group corresponding to the target data in the data packet and the group information of the group according to the group identifier in the data packet, the method further comprises: a second receiving step of sending fourth response information corresponding to each data sending end in the multiple data sending ends to each data sending end in response to multiple second packet sending requests, wherein the fourth response information is used to indicate that the third sub-data of the target data is allowed to be sent by the each data sending end; the third sub-data sent by the each data sending end is different; in the case that the fourth response information is received by the each data sending end, the third sub-data sent by the each data sending end is received; the second receiving step is cyclically executed until the complete target data is received.
[0011] In one example embodiment, after receiving the third sub-data sent by the each data sending end, the method further comprises: determining the sending speed of the third sub-data sent by the each data sending end; determining the minimum data sending end according to the sending speed of the each data sending end; and sending fifth response information to the minimum data sending end, wherein the fifth response information is used to indicate that the minimum data sending end is prohibited to send other sub-data.
[0012] In one example embodiment, after sending the target data to other receiving devices according to the group information, the method further comprises: determining whether the group disbanding information sent by the server is received, wherein the group disbanding information is used to indicate that the group is disbanded; and deleting the group information in the case that the group disbanding information sent by the server is received.
[0013] According to one embodiment of the embodiment of the present application, a data sending method is provided, comprising: determining target data to be sent, determining a group according to the target data to be sent, wherein all devices in the group are to receive the target data; sending group information of the group to all devices included in the group, wherein the group information of the group comprises: device information of multiple receiving devices for receiving the target data; sending a data packet carrying the target data to a target device in the group, to instruct the target device to, in the case that complete data packets sent by a data sending end are received, determine a group corresponding to target data in the complete data packets and group information of the group according to a group identifier in the complete data packets, and send the target data to other receiving devices according to the group information, wherein the other receiving devices are devices in the multiple receiving devices that have not received complete target data.
[0014] In one example embodiment, after sending the data packet carrying the target data to the target device in any of the groups, the method further comprises: sending a second packet sending request to all devices in any of the groups, wherein the second packet sending request comprises a hash value of the target data; receiving third response information sent by all devices respectively; in the case that all of the third response information indicates that the device corresponding to the third response information has received the complete target data, sending group disbanding information to all devices in any of the groups, wherein the group disbanding information is used to indicate disbanding any of the groups, so that all devices in any of the groups receive the group disbanding information sent by the server and disband any of the groups according to the group disbanding information.
[0015] In one example embodiment, after sending the data packet carrying the target data to the target device in any of the groups, the method further comprises: sending a second packet sending request to all devices in any of the groups, wherein the second packet sending request comprises a hash value of the target data; receiving third response information sent by all devices respectively; in the case that all of the third response information indicates that the device corresponding to the third response information has received the complete target data, sending group disbanding information to all devices in any of the groups, wherein the group disbanding information is used to indicate disbanding any of the groups, so that all devices in any of the groups receive the group disbanding information sent by the server and disband any of the groups according to the group disbanding information.
[0016] According to another embodiment of the embodiment of the present application, a data sending device is further provided, comprising: a first determining module, configured to determine a group corresponding to target data in a data packet and group information of the group according to a group identifier in the data packet in the case that the complete data packet sent by a data sending end is received, wherein the group information of the group comprises device information of a plurality of receiving devices used to receive the target data; and a first sending module, configured to send the target data to other receiving devices according to the group information, wherein the other receiving devices are devices in the plurality of receiving devices which do not receive the complete data packet.
[0017] According to another embodiment of the present application, a data sending device is also provided, comprising: a second determining module, configured to determine target data to be sent, and determine a group according to the target data to be sent, wherein all devices in the group are to receive the target data; a second sending module, configured to send group information of the group to all devices included in the group, wherein the group information of the group comprises device information of a plurality of receiving devices for receiving the target data; and a third sending module, configured to send a data packet carrying the target data to a target device in the group, so as to instruct the target device to, in a case that a complete data packet is received from a data sending end, determine a group corresponding to target data in the complete data packet and group information of the group according to a group identifier in the complete data packet, and send the target data to other receiving devices according to the group information, wherein the other receiving devices are devices in the plurality of receiving devices that do not receive the complete target data.
[0018] According to still another aspect of the present application, a computer readable storage medium is also provided, which stores a computer program, wherein the computer program is configured to execute the above method when running.
[0019] According to still another aspect of the present application, an electronic device is also provided, which comprises a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor executes the above method through the computer program.
[0020] In the embodiment of the present application, in a case that a complete data packet is received from a data sending end, a group corresponding to target data in the complete data packet and group information of the group are determined according to a group identifier in the complete data packet, wherein the group information of the group comprises device information of a plurality of receiving devices for receiving the target data; and the target data is sent to other receiving devices according to the group information, wherein the other receiving devices are devices in the plurality of receiving devices that do not receive the complete target data; by using the above technical solution, the problem that, when a server initiates a data transmission task to a plurality of device ends, the overall time consumption is relatively long due to the limitation of CPU of a single server, and other tasks are blocked, and the like, is solved, thereby achieving the technical effects of reducing the pressure of the server and improving the efficiency of data synchronization. BRIEF DESCRIPTION OF DRAWINGS
[0021] The accompanying drawings, which are included to provide a further understanding of the present application and constitute a part of this application, illustrate certain illustrative embodiments of the present application and together with the description help explain the present application. In the drawings:
[0022] Figure 1 is a hardware structure block diagram of a computer terminal of a data sending method according to an embodiment of the present application;
[0023] Figure 2 is a flow chart of a data sending method according to an embodiment of the present application;
[0024] Figure 3 is a flow chart of a data sending method according to another embodiment of the present application;
[0025] Figure 4 is a relationship schematic diagram of data packets according to an optional embodiment of the present application;
[0026] Figure 5 is a system schematic diagram of a data sending method according to an optional embodiment of the present application;
[0027] Figure 6 is a schematic diagram of a data sending method according to an optional embodiment of the present application;
[0028] Figure 7 is a flow chart of a data sending method according to an optional embodiment of the present application;
[0029] Figure 8 is a protocol format schematic diagram of a data sending method according to an optional embodiment of the present application;
[0030] Figure 9 is a structure block diagram of a data sending device according to an embodiment of the present application;
[0031] Figure 10 is a structure block diagram of a data sending device according to another embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to make the personnel in the art better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all the other embodiments obtained by the personnel in the art without creative labor should belong to the protection scope of the present application.
[0033] It should be noted that the terms "first", "second", and the like in the description and in the claims of the present application and the above-described accompanying drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or device that includes a series of steps or units does not have to be limited to only those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0034] The method embodiments provided by the embodiments of the present application can be executed in a computer terminal or similar computing device. Taking a computer terminal as an example, Figure 1 is a hardware structure block diagram of a computer terminal of a data sending method according to an embodiment of the present application. As shown in Figure 1 , the computer terminal can include one or more (only one is shown in Figure 1 ) processors 102 (the processor 102 can 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. In an exemplary embodiment, the above-mentioned computer terminal can further include a transmission device 106 for communication function and an input and output device 108. Those skilled in the art can understand that Figure 1 the structure shown is only schematic, which does not limit the structure of the above-mentioned computer terminal. For example, the computer terminal can further include more or fewer components than those shown in Figure 1 , or have a different configuration with the same function or more function than that shown in Figure 1 . Figure 1
[0035] The memory 104 can be used to store computer programs, for example, software programs of application software and modules, such as the computer program corresponding to the method in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above-mentioned method. The memory 104 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 104 can further include a memory remotely arranged with respect to the processor 102, which can be connected to the computer terminal through 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 a combination thereof.
[0036] The transmission device 106 is configured to receive or send data via a network. The network can include a wireless network provided by a communication provider of a computer terminal. In one example, the transmission device 106 includes a network adapter (NIC) that can be connected to other network devices through a base station to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module configured to communicate with the Internet wirelessly.
[0037] In the embodiment, a data sending method is provided, which is applied to a terminal device, Figure 2 is a flowchart of the data sending method according to the embodiment of the application, and the flowchart includes the following steps:
[0038] In step S202, when a complete data packet sent by a data sending end is received, a group corresponding to target data in the data packet and group information of the group are determined according to a group identifier in the data packet, wherein the group information of the group includes device information of a plurality of receiving devices for receiving the target data.
[0039] It should be noted that the data sending end includes but is not limited to a server and other devices in the group; the number of the data sending ends is one or more, and the embodiment of the application does not limit the number.
[0040] In step S204, the target data is sent to other receiving devices according to the group information, wherein the other receiving devices are devices in the plurality of receiving devices that have not received the complete target data.
[0041] Through the above steps, when a complete data packet sent by a data sending end is received, a group corresponding to target data in the data packet and group information of the group are determined according to a group identifier in the data packet, wherein the group information of the group includes device information of a plurality of receiving devices for receiving the target data; the target data is sent to other receiving devices according to the group information, wherein the other receiving devices are devices in the plurality of receiving devices that have not received the complete target data; and the above technical solution solves the problem that when a server initiates a data transmission task to a plurality of device ends, the CPU of the single server is limited, the overall time consumption is relatively long, and other tasks are blocked, thereby reducing the pressure of the server and improving the efficiency of data synchronization.
[0042] It should be noted that when the server synchronizes data to the device, the data sent to different devices often has the same part, for example, the same personnel information is sent to the database of multiple access control devices of the same floor, and the same license plate number is sent to multiple barriers of the same park, and therefore, the server divides the devices receiving the same data into the same group, and then in the case that the devices in the group receive complete data, the server synchronizes data to other devices in the group.
[0043] There are many implementation manners of the above step S204, in an exemplary embodiment, the sending step: sending a first packet sending request to any receiving device in the other receiving devices, wherein the first packet sending request comprises the hash value of the target data; in the case that the any receiving device determines that the target data is not received according to the hash value, receiving first response information of the any receiving device, wherein the first response information is used to indicate that the first sub-data of the target data is sent to the any receiving device; sending the first sub-data to the any receiving device; and circularly executing the sending step until the second response information is received, wherein the second response information is used to indicate that the any receiving device has received complete target data.
[0044] That is, when the device receiving complete target data synchronizes the target data to any receiving device in the other receiving devices in the group, for example, when the device 1 receiving complete target data synchronizes the target data to the device 2, it comprises:
[0045] Step 1: the device 1 sends a first packet sending request carrying the hash value of the target data to the device 2;
[0046] Step 2: the device 2 determines whether the device 2 receives complete target data according to the hash value in the first packet sending request;
[0047] Step 3: in the case that it is determined that complete target data is not received, determining the first sub-data that needs to be sent by the device 1;
[0048] It should be noted that the device 2 divides the complete target data into multiple segments, as shown in Figure 6 When a data source initiates a packet sending request to the device 2, the device 2 replies to one of the segments of the target data in the response information.
[0049] Step 4: sending the first response information used to indicate that the first sub-data of the target data is sent to the device 2 to the device 1;
[0050] Step 5: the device 1 sends the first sub-data to the device 2 according to the first response information;
[0051] Step 6: Steps 1-5 are repeated until a second response message is received indicating that the receiving device 2 has received the complete target data.
[0052] It should be noted that, by the above embodiment, the sending device sends a packet request to the receiving device before sending the target data, and sends part of the target data to the receiving device according to the response message of the receiving device, thereby avoiding the receiving device receiving duplicate target data, and improving the data sending efficiency.
[0053] In one example embodiment, before step S202, it includes: receiving a second packet request sent by the data sending end, wherein the second packet request includes a hash value of the target data; determining whether the complete target data is received according to the hash value; and in the case that the complete target data is not successfully received, determining to receive the data packet sent by the data sending end.
[0054] Optionally, in the case that the complete target data is successfully received by the data receiving end, a response message indicating that the data receiving end has received the complete target data is sent to the data sending end.
[0055] In one example embodiment, before determining the group corresponding to the target data in the data packet and the group information of the group according to the group identifier in the data packet, it includes: a first receiving step: sending a third response message to the data sending end in response to the second packet request, wherein the third response message is used to indicate that the data sending end is allowed to send a second sub-data of the target data; in the case that the data sending end receives the third response message, receiving the second sub-data sent by the data sending end; and repeating the first receiving step until the complete target data is received.
[0056] For example, the device 1 receives the target data sent by the device 3, which includes:
[0057] Step 1: receiving a packet request sent by the device 3 carrying a hash value of the target data;
[0058] Step 2: the device 1 determines whether the complete target data is received by the device 1 according to the hash value in the packet request;
[0059] Step 3: in the case that it is determined that the complete target data is not received, determining the sub-data that needs to be sent by the device 3;
[0060] It should be noted that the device 1 divides the complete target data into multiple segments, such as Figure 6 When a data source initiates a packet request to it, the device 1 replies to the request for one of the segments of the target data in the response message.
[0061] Step 4: sending response information to device 3 for indicating sending sub-data of the target data to device 3;
[0062] Step 5: receiving sub-data sent by device 3 according to the response information;
[0063] Step 6: repeating steps 1-5 until receiving the complete target data, and sending response information to device 3 for indicating that device 1 has received the complete target data.
[0064] In an exemplary embodiment, the number of data sending ends is multiple, and before determining the group corresponding to the target data in the data packet and the group information of the group according to the group identification in the data packet, the method further comprises a second receiving step: in response to a plurality of second packet sending requests, sending fourth response information corresponding to each data sending end in the plurality of data sending ends to each data sending end, respectively, wherein the fourth response information is used to indicate that the third sub-data of the target data is allowed to be sent by each data sending end; the third sub-data sent by each data sending end is different; receiving the third sub-data sent by each data sending end in the case that each data sending end receives the fourth response information; and repeating the second receiving step until the complete target data is received.
[0065] It should be noted that the receiving device allows multiple devices to continuously send data to it, for example, the receiving device allows 2 devices to continuously send data to it.
[0066] For example, device 1 receives target data sent by device 3 and device 4, which includes:
[0067] Step 1: receiving packet sending request 1 and sending request 2 sent by device 3 and device 4, respectively, which carry the hash value of the target data;
[0068] Step 2: determining whether device 1 receives the complete target data according to the hash value in the packet sending request 1 and the sending request 2;
[0069] Step 3: in the case that it is determined that the complete target data is not received, determining that sub-data 1 sent by device 3 and sub-data 2 sent by device 4 are needed;
[0070] It should be noted that device 1 will divide the complete target data into multiple segments, as shown in Figure 6 When a data source initiates a packet sending request to it, device 1 will reply to one of the segments in the response information, for example, sub-data 1 and sub-data 2.
[0071] Step 4: sending response information 1 to device 3 for indicating sending sub-number 1 of the target data, and sending response information 2 to device 4 for indicating sending sub-number 2 of the target data;
[0072] Step 5: receiving sub-data 1 sent by device 3 according to the response information and sub-data 2 sent by device 4 according to the response information;
[0073] Step 6: repeating steps 1-5 until receiving the complete target data, and sending response information to device 3 and device 4 for indicating that device 1 has received the complete target data.
[0074] In an exemplary embodiment, after receiving the third sub-data sent by each data sender, the method further comprises: determining the sending speed of each data sender sending the third sub-data; determining the minimum data sender according to the sending speed of each data sender; and sending fifth response information to the minimum data sender, wherein the fifth response information is used for indicating prohibiting the minimum data sender from sending other sub-data.
[0075] Optionally, due to bandwidth limitation and other services of the data sender, the sending speed of different data senders may be different. In order to select the faster data sender, the receiver sorts the sending speed of multiple data senders, and then ends the interaction with the slowest data sender. However, when the data sender includes a central server, the central server will have the highest priority. In this case, the central server will continue to send data packets carrying sub-data to the device until the device receives the complete target data.
[0076] In an exemplary embodiment, after sending the target data to other receiving devices according to the grouping information, the method further comprises: determining whether the grouping disbanding information sent by the server is received, wherein the grouping disbanding information is used for indicating disbanding the group; and deleting the grouping information in the case that the grouping disbanding information sent by the server is received.
[0077] Optionally, while the device sends data packets carrying sub-data to other receiving devices in the group, the server also sends data packets carrying sub-data to other receiving devices. If the device has received the complete target data, the server responds that the data synchronization is completed. Otherwise, the server sends data packets carrying sub-data to the device until the device receives the complete target data. When the server polls all devices in the group, it is confirmed that all devices have received the complete target data, and the server sends grouping disbanding information to all devices in the group. In the case that the grouping disbanding information is received, the grouping information is deleted.
[0078] The embodiment provides a data sending method applied to a server, Figure 3 The flowchart of the data sending method according to the embodiment of the application comprises the following steps:
[0079] In step S302, target data to be sent is determined, and a group is determined according to the target data to be sent, wherein all devices in the group are to receive the target data.
[0080] In step S304, group information of the group is sent to all devices included in the group, wherein the group information of the group comprises device information of a plurality of receiving devices for receiving the target data.
[0081] In step S306, a data packet carrying the target data is sent to a target device in the group, so as to instruct the target device to, in a case where a complete data packet sent by a data sending end is received, determine a group corresponding to the target data in the complete data packet and group information of the group according to a group identifier in the complete data packet, and send the target data to other receiving devices according to the group information, wherein the other receiving devices are devices in the plurality of receiving devices that have not received the complete target data.
[0082] Through the above steps, the target data to be sent is determined, and the group is determined according to the target data to be sent, wherein all devices in the group are to receive the target data. The group information of the group is sent to all devices included in the group, wherein the group information of the group comprises device information of a plurality of receiving devices for receiving the target data. The data packet carrying the target data is sent to the target device in the group, so as to instruct the target device to, in a case where the complete data packet sent by the data sending end is received, determine the group corresponding to the target data in the complete data packet and the group information of the group according to the group identifier in the complete data packet, and send the target data to the other receiving devices according to the group information, wherein the other receiving devices are the devices in the plurality of receiving devices that have not received the complete target data. Through the above technical solution, when the server initiates a data transmission task to a plurality of device ends, the problem that the overall time consumption is relatively long due to the limitation of CPU of a single server and other tasks are blocked is solved, and the technical effects of reducing the pressure of the server and improving the efficiency of data synchronization are achieved.
[0083] In an example embodiment, after the data packet carrying the target data is sent to the target device in any of the groups, the method further comprises: sending a second packet sending request to all devices in any of the groups, wherein the second packet sending request comprises a hash value of the target data; receiving third response information sent by all devices respectively; in the case that all of the third response information indicates that the device corresponding to the third response information has received the complete target data, sending group disbanding information to all devices in any of the groups, wherein the group disbanding information is used to indicate disbanding of any of the groups, so that all devices in any of the groups receive the group disbanding information sent by the server and disband any of the groups according to the group disbanding information.
[0084] In an example embodiment, after the data packet carrying the target data is sent to the target device in any of the groups, the method further comprises: sending a second packet sending request to all devices in any of the groups, wherein the second packet sending request comprises a hash value of the target data; receiving third response information sent by all devices respectively; in the case that all of the third response information indicates that the device corresponding to the third response information has received the complete target data, sending group disbanding information to all devices in any of the groups, wherein the group disbanding information is used to indicate disbanding of any of the groups, so that all devices in any of the groups receive the group disbanding information sent by the server and disband any of the groups according to the group disbanding information.
[0085] In order to better understand the process of the above method, the implementation method flow described above will be described in combination with optional embodiments below, but not used to limit the technical scheme of the embodiments of the present application.
[0086] In the present embodiment, a data sending method is provided. When a server synchronizes data to devices, the data sent to different devices often has the same part, for example, the same personnel information is sent to the databases of multiple access control devices of the same floor, and the same license plate number is sent to multiple barriers in the same park. Therefore, the relationship of the data packets held by different devices can be described as Figure 4 As shown in Figure 4 , the device A and the device C share the data packet 2, the device B and the device C share the data packet 3, the device A and the device B share the data packet 1, and the devices A, B and C share the data packet 1. When it is needed to synchronize the data packet 1 to the devices A, B and C, the server first divides the devices A, B and C into a group and synchronizes the group information to the devices A, B and C, and then the whole system converts the network topology structure from a star structure to a mesh topology, as shown in Figure 5 .
[0087] When one of the devices in the group receives a complete data packet, the device becomes a peer of the server, which synchronizes the data packet to other devices in the group. In the security scenario, since the initiator of the device registration to the management platform is the platform side, the device must have an externally accessible IP address, so the devices A, B and C do not need to perform network penetration again to exchange data. In the mesh topology, the more devices that receive the data packet, the more devices that can synchronize the data, and the speed of data synchronization will increase exponentially.
[0088] The specific steps are as shown in Figure 7 The specific steps are as follows:
[0089] Step S701: The server groups the devices;
[0090] Before sending the packet, the server divides the devices sharing the same data packet into a group, and notifies the device of the group and the information of other devices in the group. The same device can exist in multiple groups. Therefore, the device will hold a group table containing the group identifiers and group information of multiple groups in which the device exists. Considering that the device simultaneously maintains and links with multiple devices, the device establishes a link with other devices in the group only when starting to send the packet.
[0091] Step S702: The server groups the packet and sends the data packet;
[0092] After the grouping is completed, the server packs the data packet, and the header field of the data packet contains the device group to which the data packet is to be distributed and the hash value of the data packet. The hash value is used to uniquely mark the packet, otherwise a network storm will occur. The server randomly selects a device to send the data packet.
[0093] Step S703: The device receiving the complete data packet sends the packet to other devices in the group;
[0094] Sender: After a device receives a complete data packet, a packet sending task to other devices in the same group is generated. The priority of the packet sending task can be set to low, so that when the sender is in an idle state, the packet can be sent to other devices in the same group. Before sending the packet, the sender sends a packet sending request to the other party and carries the hash value of the data packet. If the sender is at the rear end of the distribution chain, the receiving device has probably received the packet from other devices, and the packet sending request will be rejected. The sender will allow synchronization of data to at most three devices. In this process, the sender uses a polling method to sequentially attempt to send the packet to the devices in the group. If the other party has received the data packet, it will not be attempted again. Other situations include network disconnection, abnormal termination of the receiving party, etc., and the packet will be sent again.
[0095] Receiver: As Figure 6As shown, it is noted that the packet sending request further includes: data size of the data packet, the receiver will divide the whole packet into multiple segments, when a data source initiates a packet sending request to the receiver, the receiver will ask for one segment in the reply. The receiver will allow three devices to continuously send data to it at the same time. Due to bandwidth limitation and other services of the sender, the sending speed of different data sources will be different. In order to select the faster data source, the receiver will additionally allow one data source to send several packet segment data to it, and sort the sending speed of the four data sources, and then end the interaction with the slowest data source. However, when the data source includes a server, the server will have the highest priority, and the server will continuously send packets to the device until the receiving is completed.
[0096] Step S704: The server confirms the device status.
[0097] The device sends packets to other devices in the same group, and the server also sends packets to other devices in the group. If the device has received the data packet from other devices in the same group, the device replies to the server that the data synchronization is completed. Otherwise, the server sends the data packet to the device until the device receives the data. When the server polls all devices in the group and confirms that all devices have received the data, the data synchronization process is completed.
[0098] In another exemplary embodiment, taking a campus access control security system as an example, the specific steps are as follows:
[0099] Step 801: The server associates the device with the department in the floor according to the floor position of the access control. If multiple floors are for one department, the access control devices of multiple floors are associated with the same department, and the server sets the access control devices of multiple floors as the same group.
[0100] Step 802: Send the group information to each device in the group, mainly including device IP and port information. Since the security system is generally deployed in a local area network, it can be directly accessed, otherwise network penetration is performed through port mapping.
[0101] Step 803: The server first initiates a packet to one of the devices, and includes the file hash value and the group ID to be distributed in the packet header. In the data packet, the name, number, face information, card number, fingerprint and other information of the personnel are included. After the device receives the complete data packet, the device will store these data in the database. When the personnel opens the door, the permission is verified from the database, such as Figure 8 As shown.
[0102] Step 804: After one device receives the complete data packet, the peer group synchronization process is started;
[0103] Note that, in the platform under the distribution of the device list polling device, while a maximum of three devices to send a package, the device can be set to low priority to split the task to handle other tasks at the same time.
[0104] Step 805: when the server polls all the devices, this distribution process ends, the server issues a message to the device end again, and deletes the specified group.
[0105] The embodiment of the application utilizes the idle devices in the system to perform Pareto optimization on the pressure of the central node and the efficiency of data synchronization.
[0106] Compared with the distributed system, the embodiment of the application has a faster data synchronization speed. Assuming that the center can synchronize data to N devices in a unit of time, a distributed system containing M servers can send data packets to NM devices in a unit of time, and in the embodiment of the application, the packet sending speed depends on the number of devices that have received the data packet. After the server synchronizes data to N devices in the first unit of time, the system can send data to N+NP devices in the next time period, P being the number of packets that can be sent by the Internet of Things device in a unit of time. In this way, after k time periods, the packet sending speed of the system is N+NP+NP 2 +…+NP k It can be seen that the larger the number of devices, the more obvious the advantage of the embodiment of the application.
[0107] Compared with the P2P distribution design in the Internet scenario, the embodiment of the application is more suitable for the security scenario. The data distribution is initiated by the server, and because the devices are uniformly managed by the server, the server can divide peer groups for the devices according to the business, and then notify each device of the information of the peer group to which the device belongs before initiating the distribution process, so as to replace the process of obtaining peers from the tracker server in the Internet scenario, making the distribution process more efficient, and the tracker server can also be saved. In addition, unlike the traditional P2P which distributes existing data to peers at the same time as downloading, the embodiment of the application is designed to start distribution only after downloading is completed, so that the device can write data into the storage space in sequence after obtaining the data, thus only a small cache space is needed, and the implementation is simplified, achieving a faster processing speed. The device that completes the download will continue to distribute until all peers complete the download, avoiding the problem of too few peers and lack of resources in the traditional P2P, and thus the embodiment of the application is suitable for the security scenario and is more likely to be implemented.
[0108] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software on a general hardware platform as necessary, and of course can also be realized by hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product in essence or in the form of a part of the prior art that makes a contribution. The computer software product is stored in a storage medium (such as a ROM / RAM, a magnetic disk, or an optical disk) and includes a plurality of instructions for causing a terminal device (which can be a mobile phone, a computer, a server, or a network device) to execute the method of each embodiment of the present application.
[0109] Figure 9 is a structural block diagram of a data sending device according to an embodiment of the present application; as shown in Figure 9 , comprising:
[0110] A first determination module 92 is configured to, in a case where a complete data packet sent by a data sending end is received, determine a group corresponding to target data in the data packet and group information of the group according to a group identifier in the data packet, wherein the group information of the group includes device information of a plurality of receiving devices for receiving the target data.
[0111] A first sending module 94 is configured to send the target data to other receiving devices according to the group information, wherein the other receiving devices are devices in the plurality of receiving devices that have not received the complete data packet.
[0112] Through the above device, in a case where a complete data packet sent by a data sending end is received, a group corresponding to target data in the data packet and group information of the group are determined according to a group identifier in the data packet, wherein the group information of the group includes device information of a plurality of receiving devices for receiving the target data; the target data is sent to other receiving devices according to the group information, wherein the other receiving devices are devices in the plurality of receiving devices that have not received the complete target data; by using the above technical solution, the problems that when a server initiates a data transmission task to a plurality of device ends, due to the limitation of a CPU of a single server, the overall time consumption is relatively long, and other tasks are blocked, and the like are solved, and the technical effects of reducing the pressure of the server and improving the efficiency of data synchronization are achieved.
[0113] In one example embodiment, the first sending module 94 is configured to perform a sending step of sending a first packet request to any of the other receiving devices, wherein the first packet request comprises a hash value of the target data; receiving first response information from the any of the other receiving devices in a case that the any of the other receiving devices determines that the target data is not received according to the hash value, wherein the first response information is used to indicate sending a first sub-data of the target data to the any of the other receiving devices; sending the first sub-data to the any of the other receiving devices; and repeating the sending step until second response information is received, wherein the second response information is used to indicate that the any of the other receiving devices has received the complete target data.
[0114] In one example embodiment, the device further comprises a receiving module configured to receive a second packet request sent by the data sending end, wherein the second packet request comprises a hash value of the target data; determine whether the complete target data is received according to the hash value; and determine to receive a data packet sent by the data sending end in a case that the complete target data is not successfully received.
[0115] In one example embodiment, the receiving module is configured to perform a first receiving step of sending third response information to the data sending end in response to the second packet request, wherein the third response information is used to indicate allowing the data sending end to send a second sub-data of the target data; receive the second sub-data sent by the data sending end in a case that the data sending end receives the third response information; and repeat the first receiving step until the complete target data is received.
[0116] In one example embodiment, the receiving module is configured to perform a second receiving step of sending fourth response information corresponding to each of the data sending ends to the each of the data sending ends in response to a plurality of the second packet requests, wherein the fourth response information is used to indicate allowing the each of the data sending ends to send a third sub-data of the target data; the third sub-data sent by the each of the data sending ends is different; receive the third sub-data sent by the each of the data sending ends in a case that the each of the data sending ends receives the fourth response information; and repeat the second receiving step until the complete target data is received.
[0117] In one example embodiment, the first sending module is configured to determine a sending speed of the third sub-data sent by the each of the data sending ends; determine a minimum data sending end according to the sending speed of the each of the data sending ends; and send fifth response information to the minimum data sending end, wherein the fifth response information is used to indicate prohibiting the minimum data sending end to send other sub-data.
[0118] In one example embodiment, a first determining module is configured to determine whether a packet disbanding information sent by a server is received, wherein the packet disbanding information is used to indicate disbanding the group; and delete the group information in a case that the packet disbanding information sent by the server is received.
[0119] Figure 10 is a structural block diagram of a data sending device according to another embodiment of the present application; as shown in Figure 10 the drawing, the device comprises:
[0120] A second determining module 102 is configured to determine target data to be sent, and determine a group according to the target data to be sent, wherein all devices in the group are to receive the target data;
[0121] A second sending module 104 is configured to send group information of the group to all devices included in the group, wherein the group information of the group comprises device information of a plurality of receiving devices used to receive the target data;
[0122] A third sending module 106 is configured to send a data packet carrying the target data to a target device in the group, so as to instruct the target device to, in a case that a complete data packet sent by a data sending end is received, determine a group corresponding to target data in the complete data packet and group information of the group according to a group identifier in the complete data packet, and send the target data to other receiving devices according to the group information, wherein the other receiving devices are devices in the plurality of receiving devices which have not received the complete target data.
[0123] The second determining module determines target data to be sent, determines a group according to the target data to be sent, all devices in the group are to receive the target data, the second sending module sends group information of the group to all devices included in the group, the group information of the group includes device information of a plurality of receiving devices for receiving the target data, and the third sending module sends a data packet carrying the target data to a target device in the group to instruct the target device to determine a group corresponding to target data in a complete data packet according to a group identifier in the complete data packet and group information of the group in a case where the target device receives the complete data packet sent by the data sending end, and send the target data to other receiving devices according to the group information, the other receiving devices being devices that do not receive the complete target data in the plurality of receiving devices. By using the technical solution, when the server initiates a data transmission task to a plurality of device ends, the problem that the overall time consumption is relatively long due to the limited CPU of a single server and other tasks are blocked is solved, and the technical effects of reducing the pressure of the server and improving the efficiency of data synchronization are achieved.
[0124] In an example embodiment, the third sending module 106 is configured to perform a sending step of sending a first packet sending request to the target device, wherein the first packet sending request includes a hash value of the target data; receiving first response information of the target device in a case where the target device determines that the target data is not received according to the hash value, wherein the first response information is used to instruct to send a first sub-data of the target data to the target device; sending the first sub-data to the target device; and cyclically performing the sending step until second response information is received, wherein the second response information is used to indicate that the target device has received complete target data.
[0125] In an example embodiment, the third sending module 106 is configured to send a second packet sending request to all devices in any group, wherein the second packet sending request includes a hash value of the target data; receive third response information sent by all devices respectively; and send group disbanding information to all devices in any group in a case where a plurality of the third response information are used to indicate that the devices corresponding to the third response information have received complete target data, wherein the group disbanding information is used to instruct to disband the any group, so that all devices in the any group receive the group disbanding information sent by the server and disband the any group according to the group disbanding information.
[0126] Embodiments of the present application also provide a storage medium including a stored program, wherein the program performs any of the above methods when executed.
[0127] Optionally, in the embodiment, the storage medium can be configured to store program code for performing the following steps:
[0128] S11, in the case of receiving a complete data packet sent by a data sending end, determining a group corresponding to target data in the data packet and group information of the group according to a group identifier in the data packet, wherein the group information of the group comprises device information of a plurality of receiving devices for receiving the target data;
[0129] S12, sending the target data to other receiving devices according to the group information, wherein the other receiving devices are devices in the plurality of receiving devices that do not receive the complete target data.
[0130] Optionally, in the embodiment, the storage medium can be configured to store program code for performing the following steps:
[0131] S21, determining target data to be sent, and determining a group according to the target data to be sent, wherein all devices in the group are to receive the target data;
[0132] S22, sending group information of the group to all devices included in the group, wherein the group information of the group comprises device information of a plurality of receiving devices for receiving the target data;
[0133] S23, sending a data packet carrying the target data to a target device in the group, to instruct the target device, in the case of receiving a complete data packet sent by a data sending end, to determine a group corresponding to target data in the complete data packet and group information of the group according to a group identifier in the complete data packet, and to send the target data to other receiving devices according to the group information, wherein the other receiving devices are devices in the plurality of receiving devices that do not receive the complete target data.
[0134] Embodiments of the present application also provide an electronic device comprising a memory and a processor, the memory storing a computer program, and the processor being configured to run the computer program to perform the steps in any of the above method embodiments.
[0135] Optionally, the electronic device can further comprise 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.
[0136] Optionally, in the embodiment, the processor can be configured to perform the following steps through the computer program:
[0137] S11, in a case where a complete data packet sent by a data sending end is received, determining, according to a packet identifier in the data packet, a packet corresponding to target data in the data packet and packet information of the packet, wherein the packet information of the packet comprises device information of a plurality of receiving devices for receiving the target data;
[0138] S12, sending the target data to other receiving devices according to the packet information, wherein the other receiving devices are devices in the plurality of receiving devices that have not received the complete target data.
[0139] Optionally, in the embodiment, the processor can be configured to execute the following steps by using a computer program:
[0140] S21, determining target data to be sent, and determining a packet according to the target data to be sent, wherein all devices in the packet are to receive the target data;
[0141] S22, sending packet information of the packet to all devices included in the packet, wherein the packet information of the packet comprises device information of a plurality of receiving devices for receiving the target data;
[0142] S23, sending a data packet carrying the target data to a target device in the packet, to instruct the target device, in a case where a complete data packet sent by a data sending end is received, to determine, according to a packet identifier in the complete data packet, a packet corresponding to target data in the complete data packet and packet information of the packet, and to send the target data to other receiving devices according to the packet information, wherein the other receiving devices are devices in the plurality of receiving devices that have not received the complete target data.
[0143] Optionally, in the embodiment, the storage medium can include, but is not limited to, a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.
[0144] Optionally, specific examples in the embodiment can refer to examples described in the above embodiments and optional implementation manners, and the embodiment will not be described here again.
[0145] It should be apparent to those skilled in the art that the modules or steps of the application described above can be implemented with general computing devices, which can be centralized on a single computing device or distributed on a network of multiple computing devices, and optionally implemented with program codes executable by the computing devices, which can be stored in storage devices and executed by the computing devices, and in some cases, the steps shown or described can be executed in an order different from that shown, or made into individual integrated circuit modules, or made into a single integrated circuit module. Thus, the present application is not limited to any particular combination of hardware and software.
[0146] The preferred embodiments of the present application described above are only used to explain the principles of the present application and should not be used to limit the scope of the present application. Any modification, equivalent replacement, improvement, etc. within the principles of the present application should be included in the scope of the present application.
Claims
1. A method for transmitting data, characterized in that, include: Upon receiving a complete data packet sent by the data sender, the packet corresponding to the target data in the data packet and the packet information of the packet are determined according to the packet identifier in the data packet. The packet information of the packet includes: device information of multiple receiving devices used to receive the target data. The target data is sent to other receiving devices according to the grouping information, wherein the other receiving devices are those among the plurality of receiving devices that have not received the complete target data.
2. The data transmission method according to claim 1, characterized in that, Sending the target data to other receiving devices according to the packet information includes: Sending steps: Send a first packet request to any of the other receiving devices, wherein the first packet request includes the hash value of the target data; if any receiving device determines that it has not received the target data based on the hash value, receive first response information from the receiving device, wherein the first response information is used to instruct the sending of first sub-data of the target data to the receiving device; send the first sub-data to the receiving device. The sending step is repeated until a second response message is received, wherein the second response message is used to indicate that either receiving device has received the complete target data.
3. The data transmission method according to claim 1, characterized in that, Before determining the packet corresponding to the target data in the data packet and the packet information of the packet based on the packet identifier in the data packet, the method further includes: Receive a second packet sending request sent by the data sending end, wherein the second packet sending request includes the hash value of the target data; Determine whether the complete target data has been received based on the hash value; If the complete target data is not successfully received, determine to receive the data packet sent by the data sending end.
4. The data transmission method according to claim 3, characterized in that, Before determining the packet corresponding to the target data in the data packet and the packet information of the packet based on the packet identifier in the data packet, the method further includes: First receiving step: In response to the second packet sending request, send a third response information to the data sending end, wherein the third response information is used to indicate that the data sending end is allowed to send the second sub-data of the target data; if the data sending end receives the third response information, receive the second sub-data sent by the data sending end; The first receiving step is executed repeatedly until the complete target data is received.
5. The data transmission method according to claim 3, characterized in that, The number of data sending ends is multiple. Before determining the packet corresponding to the target data in the data packet and the packet information of the packet based on the packet identifier in the data packet, the method further includes: Second receiving step: In response to multiple second packet sending requests, send a fourth response information corresponding to each of the multiple data sending ends, wherein the fourth response information is used to indicate that each data sending end is allowed to send the third sub-data of the target data; the third sub-data sent by each data sending end is different; when each data sending end receives the fourth response information, receive the third sub-data sent by each data sending end; The second receiving step is repeated until the complete target data is received.
6. The data transmission method according to claim 5, characterized in that, After receiving the third sub-data sent by each data sender, the method further includes: Determine the transmission speed at which each data transmitter sends the third sub-data; The minimum data sender is determined based on the sending speed of each data sender; A fifth response message is sent to the minimum data sender, wherein the fifth response message is used to instruct the minimum data sender to prohibit the sender from sending other sub-data.
7. The data transmission method according to claim 1, characterized in that, After sending the target data to other receiving devices according to the packet information, the method further includes: Determine whether a packet disbanding message has been received from the server, wherein the packet disbanding message is used to indicate the disbanding of the packet; Upon receiving the group disbanding information sent by the server, the group information is deleted.
8. A method for transmitting data, characterized in that, include: The target data to be sent is determined, and a group is determined based on the target data to be sent, wherein all devices in the group are to receive the target data; The packet information is sent to all devices included in the packet, wherein the packet information includes: device information of multiple receiving devices for receiving the target data; A data packet carrying the target data is sent to the target device in the group, so as to instruct the target device, upon receiving a complete data packet sent by the data sender, to determine the group corresponding to the target data in the complete data packet and the group information of the group based on the group identifier in the complete data packet, and to send the target data to other receiving devices based on the group information, wherein the other receiving devices are devices among the plurality of receiving devices that have not received the complete target data.
9. The data transmission method according to claim 8, characterized in that, Sending a data packet carrying the target data to the target device in the group includes: Sending steps: Send a first packet request to the target device, wherein the first packet request includes a hash value of the target data; if the target device determines that it has not received the target data based on the hash value, receive first response information from the target device, wherein the first response information is used to instruct the sending of first sub-data of the target data to the target device; send the first sub-data to the target device; The sending step is repeated until a second response message is received, wherein the second response message is used to indicate that the target device has received the complete target data.
10. The data transmission method according to claim 8, characterized in that, After sending a data packet carrying the target data to the target device in the group, the method further includes: Send a second packet request to all devices in any group, wherein the second packet request includes the hash value of the target data; Receive the third response information sent by each of the aforementioned devices; When multiple third response messages are used to indicate that the device corresponding to the third response message has received the complete target data, a group disbanding message is sent to all devices in any group, wherein the group disbanding message is used to indicate the disbanding of any group, so that all devices in any group receive the group disbanding message sent by the server and disband any group according to the group disbanding message.
11. A data transmission device, characterized in that, include: The first determining module is used to determine, upon receiving a complete data packet sent by the data sending end, the packet corresponding to the target data in the data packet and the packet information of the packet based on the packet identifier in the data packet, wherein the packet information of the packet includes: device information of multiple receiving devices for receiving the target data; The first sending module is used to send the target data to other receiving devices according to the packet information, wherein the other receiving devices are devices among the plurality of receiving devices that have not received the complete data packet.
12. A data transmission device, characterized in that, include: The second determining module is used to determine the target data to be sent and to determine a group based on the target data to be sent, wherein all devices in the group are to receive the target data; The second sending module is used to send the packet information of the packet to all devices included in the packet, wherein the packet information of the packet includes: device information of multiple receiving devices for receiving the target data; The third sending module is used to send a data packet carrying the target data to the target device in the packet, so as to instruct the target device, upon receiving a complete data packet sent by the data sending end, to determine the packet corresponding to the target data in the complete data packet and the packet information of the packet according to the packet identifier in the complete data packet, and to send the target data to other receiving devices according to the packet information, wherein the other receiving devices are devices among the plurality of receiving devices that have not received the complete target data.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method described in any one of claims 1 to 7, or the method described in any one of claims 8 to 10.
14. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 7, or the method described in any one of claims 8 to 10, through the computer program.
Citation Information
Patent Citations
Data wireless transmission method and device, computer equipment and storage medium
CN110913431A
Data Transfer Method, System and Protocol
US20090287844A1