Data transmission method and device, related equipment and computer program product
By building a hierarchical peer network architecture, node equipment is intelligently connected and monitored in the LAN, solving the problem of excessive connection load during peak attendance, achieving efficient and reliable data transmission and disaster recovery capabilities, and is suitable for educational informatization system.
Patent Information
- Application Number
- CN202411578758.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-11-07
AI Technical Summary
During the peak attendance period of LAN equipment, due to the large number of equipment and frequent data reporting, the connection load of each node device is too large, and the server faces huge pressure on data processing and connection management, affecting the efficiency and reliability of the attendance system.
Build a hierarchical peer network architecture. The node equipment intelligently connects superior and adjacent node equipment at the same level according to the connection instructions sent by the server to form an initial network, and monitors the status of the node equipment in real time through heartbeat communication detection, dynamically adjusts the network structure, and ensures the network Stable and efficient.
It realizes the hierarchical management of node equipment, reduces connection load, enhances disaster recovery capabilities, ensures data continuity and integrity, improves data reporting efficiency, and adapts to the needs of low-performance equipment such as electronic squad cards.
Smart Images

Figure CN119071305A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a data transmission method, apparatus, related equipment and computer program product. Background Art
[0002] In the application scenarios of LAN devices, especially in school environments, electronic class cards have become an important means of daily attendance. Attendance activities are often concentrated in specific time periods, such as get out of class start and end times, which prompts a large number of node devices (i.e. electronic class cards) to report high-frequency attendance data in a short period of time. This data is crucial for subsequent attendance processing and analysis, so it needs to be collected and uploaded to the server in a timely and accurate manner.
[0003] At present, the existing technology mainly relies on each terminal device to directly report the attendance data to the server. That is, after the attendance is completed, each device sends the attendance data to the server through the local area network. The server is responsible for receiving, storing and processing these attendance data.
[0004] However, during peak attendance periods, due to the large number of devices and frequent data reporting, the connection load of each node device will be too large, and the server will also face huge data processing and connection management pressure. Summary of the invention
[0005] The present disclosure provides a data transmission method, apparatus, related equipment and computer program product.
[0006] According to a first aspect of the present disclosure, a data transmission method is provided, the method being applied to a node device, the method comprising: Receive a connection instruction sent by the server, the connection instruction including the device number of the upper node device and the adjacent node device at the same level to be connected; Establish connections with the upper node device and the same-level adjacent node device corresponding to the device number respectively, and obtain an initial peer-to-peer network based on the connection results, in which the number of node devices between the upper node device and the lower node device in the initial peer-to-peer network meets the preset ratio; Heartbeat communication detection is performed on the upper node device and the adjacent node device at the same level. According to the heartbeat communication detection result, the initial peer-to-peer network is updated to obtain an updated peer-to-peer network, so as to realize data transmission between the node device and the server by using the updated peer-to-peer network.
[0007] In some implementations of the present disclosure, obtaining an initial peer-to-peer network according to the connection result includes: If the connection result is a connection failure, the connection failure information is fed back to the server, and the connection failure information includes the device number of the abnormal node device among the upper node device and the adjacent node devices at the same level; receiving an update connection instruction sent by the server, where the update connection instruction includes a device number of a replacement node device corresponding to the abnormal node device; Based on the device number of the replacement node device in the update connection instruction, the abnormal node device connected is replaced with the replacement node device to obtain an initial peer-to-peer network; If the connection result is successful, the node information of the upper node device and the adjacent node device at the same level is stored to obtain the initial peer-to-peer network, and the connection success information is fed back to the server.
[0008] In some embodiments of the present disclosure, if the connection result is a successful connection, the node information of the upper node device and the adjacent node device of the same level is stored to obtain an initial peer-to-peer network, and the connection success information is fed back to the server. Thereafter, the method includes: A disconnection task is sent to a peer adjacent node device, where the disconnection task is used to instruct the peer adjacent node device to disconnect from the first node device in the hierarchy of the node devices.
[0009] In some embodiments of the present disclosure, heartbeat communication detection is performed on the upper node device and the adjacent node device at the same level, and the initial peer-to-peer network is updated according to the heartbeat communication detection result, and the updated updated peer-to-peer network includes: If the heartbeat of the first node device among the upper node device and the adjacent node devices at the same level is detected to be abnormal, the heartbeat abnormality result of the first node device is sent to the server; Receive a reconnection instruction sent by a substitute node device corresponding to the first node device, replace the connected first node device with the substitute node device, and obtain an updated peer-to-peer network. The reconnection instruction sent by the substitute node device is generated based on the replacement connection instruction sent by the server. The replacement connection instruction is used to instruct the substitute node device to replace the first node device.
[0010] In some embodiments of the present disclosure, a heartbeat communication detection is performed on an upper-level node device and an adjacent node device at the same level, and an initial peer-to-peer network is updated according to the heartbeat communication detection result to obtain an updated peer-to-peer network. Thereafter, the method includes: The transmission data is sent to the upper node device and the same-level adjacent node device corresponding to the updated peer network respectively, so that the upper node device and the same-level adjacent node device can be used to send the transmission data to the first-level node device. The first-level node device is directly connected to the server, and the first-level node device is used to send the received transmission data to the server.
[0011] In some embodiments of the present disclosure, sending the transmission data to the upper node device and the same-level adjacent node device corresponding to the updated peer network respectively includes: If the number of routes between the upper node device and the upper node device is less than the preset routing threshold, and the transmission data is not historical transmission data, the transmission data is sent to the upper node device. If the number of routing times between adjacent node devices at the same level is less than a preset routing threshold, and the transmission data is not historical transmission data, the routing times are updated, and the transmission data is sent to the adjacent node devices at the same level.
[0012] According to a second aspect of the present disclosure, a data transmission method is provided, the method being applied to a server, the method comprising: Determine the device number of the node device according to the registration request time of the node device; According to the device number of the node device, determine the device numbers of the upper node device and the adjacent node devices at the same level that need to be connected to the node device; A connection instruction is formed according to the device number and sent to the node device. The connection instruction includes the device numbers of the upper node device and the adjacent node device at the same level that need to be connected to the node device.
[0013] In some implementations of the present disclosure, determining the device numbers of the upper-level node device and the same-level adjacent node device to be connected to the node device according to the device number of the node device includes: If the device number of the node device is less than or equal to the preset proportional factor corresponding to the preset proportion, the device numbers of the upper node device and the adjacent node devices at the same level that need to be connected to the node device are determined according to the node device list, and the preset proportional factor is used to adjust the number of node devices between the upper node device and the lower node device to meet the preset proportion; If the device number of the node device is greater than the preset proportional factor, the device numbers of the upper node device and the same-level adjacent node devices that need to be connected to the node device are determined according to the device number of the node device and the preset proportional factor.
[0014] In some implementations of the present disclosure, determining the device numbers of the upper-level node device and the same-level adjacent node device to be connected to the node device according to the device number of the node device and the preset scale factor includes: Determine the level of the node device according to the device number of the node device and the preset scale factor; Determine a first device number of a first node device in the hierarchy according to the hierarchy of the node device and a preset scale factor; Determine the device number of the upper-level node device corresponding to the node device according to the first device number, the device number of the node device, and the preset proportional factor; According to the device number of the node device and the preset scale factor, the device number of the adjacent node device at the same level corresponding to the node device is determined.
[0015] In some implementations of the present disclosure, determining the level of the node device according to the device number of the node device and the preset scale factor includes: According to the following formula 1, the level of the node device is determined according to the device number of the node device and the preset scale factor: Formula 1 Wherein, L is the level of the node device, P is the device number of the node device, and N is the preset scaling factor; According to the following formula 2, the first device number in the hierarchy is determined according to the hierarchy of the node device and the preset scale factor: Formula 2 in, is the first device number of the first node device in the hierarchy of node devices, N is a preset scale factor, and L is the hierarchy of the node device; According to the following formula 3, the device number of the upper-level node device corresponding to the node device is determined according to the first device number, the device number of the node device, and the preset proportional factor: Formula 3 in, is the device number of the upper node device corresponding to the node device, and P is the device number of the node device. is the first device number of the first node device in the hierarchy of node devices, N is a preset scale factor, and L is the hierarchy of the node device.
[0016] According to a third aspect of the present disclosure, a data transmission device is provided. The device is applied to a node device, and the device includes: A receiving unit, used to receive a connection instruction sent by a server, wherein the connection instruction includes device numbers of an upper-level node device and an adjacent node device at the same level to be connected; A construction unit is used to establish connections with the upper node device and the adjacent node device of the same level corresponding to the device number, and obtain an initial peer-to-peer network according to the connection result, wherein the number of node devices between the upper node device and the lower node device in the initial peer-to-peer network meets a preset ratio; The update unit is used to perform heartbeat communication detection on the upper node device and the adjacent node device at the same level, and update the initial peer-to-peer network based on the heartbeat communication detection result to obtain an updated peer-to-peer network, so as to use the updated peer-to-peer network to realize data transmission between the node device and the server.
[0017] According to a fourth aspect of the present disclosure, a data transmission device is provided, the device being applied to a server, the device comprising: A first determining unit, configured to determine a device number of a node device according to a registration request time of the node device; A second determining unit is used to determine the device numbers of the upper-level node device and the same-level adjacent node device that need to be connected to the node device according to the device number of the node device; The sending unit is used to form a connection instruction according to the device number and send the connection instruction to the node device. The connection instruction includes the device numbers of the upper node device and the adjacent node device at the same level that need to be connected to the node device.
[0018] According to a fifth aspect of the present disclosure, an electronic device is provided, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the method described in the first aspect or the second aspect when executing the computer program.
[0019] According to a sixth aspect of the present disclosure, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the computer program implements the method described in the first aspect or the second aspect.
[0020] The data transmission method, apparatus, related equipment and computer program product provided by the present invention receive a connection instruction sent by a server, wherein the connection instruction includes the device number of the upper node device and the adjacent node device of the same level to be connected; establish connections with the upper node device and the adjacent node device of the same level corresponding to the device number respectively, and obtain an initial peer-to-peer network based on the connection result, wherein the number of node devices between the upper node device and the lower node device in the initial peer-to-peer network meets a preset ratio; perform heartbeat communication detection on the upper node device and the adjacent node device of the same level, and update the initial peer-to-peer network based on the heartbeat communication detection result to obtain an updated updated peer-to-peer network, so as to realize data transmission between the node device and the server by using the updated peer-to-peer network, realize the construction of a hierarchical peer-to-peer network with disaster recovery capability, ensure that the node device uses heartbeat communication detection to ensure network stability, and report data to the server step by step according to the hierarchical structure, effectively disperse the data transmission pressure, improve data reporting efficiency, and reduce the connection load of each node device, thereby providing strong support for realizing an educational information system with low load, high disaster recovery capability and high transmission efficiency.
[0021] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure. Figure 1A flowchart of a data transmission method provided by an embodiment of the present disclosure; Figure 2 A flowchart of another data transmission method provided by an embodiment of the present disclosure; Figure 3 A flowchart of another data transmission method provided by an embodiment of the present disclosure; Figure 4 A flowchart of a data transmission method provided by an embodiment of the present disclosure; Figure 5 A flowchart of another data transmission method provided by an embodiment of the present disclosure; Figure 6 A schematic diagram of a specific peer-to-peer network architecture provided by an embodiment of the present disclosure; Figure 7 A schematic diagram of the structure of a data transmission device provided in an embodiment of the present disclosure; Figure 8 A schematic diagram of the structure of a data transmission device provided in an embodiment of the present disclosure; Fig. 9 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0023] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0024] In the current LAN device application scenarios, the rapid advancement of IoT technology has prompted a large number of node devices to access the network to achieve data communication. These devices include sensors, smart home appliances, surveillance cameras and other types, which need to send data to the server regularly or on demand.
[0025] Taking the school environment as an example, electronic class cards have become a common way to clock in and out for attendance. Since attendance activities are often concentrated in a specific time period, such as before and after classes, this will cause many node devices to report high-frequency data in a short period of time. These attendance data need to be collected and uploaded to the server in a timely manner for subsequent data processing and analysis.
[0026] At present, the relevant technology is that each node device independently reports the attendance data to the server. After completing the attendance record, the node device directly transmits the data to the server through the local area network. The server is responsible for receiving, storing and processing this data.
[0027] However, during the peak attendance period, a large number of node devices report data at the same time, causing a sharp increase in the connection load of each node device; and the server is also under tremendous pressure to process data and manage connections when processing massive concurrent data requests. This may not only prolong the server's response time, but also cause data loss or processing delays, thus affecting the efficiency and reliability of the entire attendance system.
[0028] In order to solve the problems in the related art, the data transmission method proposed in the present disclosure constructs a hierarchical peer-to-peer network architecture with strong disaster recovery capabilities. The node device intelligently connects to the upper and adjacent node devices at the same level according to the connection instructions sent by the server to form an initial network and ensure that the number of nodes between the levels meets the preset ratio. The node device status is monitored in real time through heartbeat communication detection and the network structure is dynamically adjusted to achieve continuous stability and high efficiency of the network. The architecture realizes the hierarchical management of node devices, the node devices at the same level form a ring structure to share data, and the adjacent node devices at the same level are dispersedly connected to different upper node devices to enhance disaster recovery capabilities. Even if the upper node device fails, the child node device can still report data through the adjacent node device to ensure data continuity and integrity. The connection load of the node device is reduced, and the needs of low-performance devices such as electronic class signs are adapted, so that the network has excellent disaster recovery capabilities while running efficiently.
[0029] The data transmission method, apparatus, electronic device, storage medium, and computer program product according to the embodiments of the present disclosure are described below with reference to the accompanying drawings.
[0030] Figure 1 The following is a flow chart of a data transmission method provided by an embodiment of the present disclosure. Figure 1 As shown, the method is applied to a node device, and the method includes: Step 101: receiving a connection instruction sent by a server, where the connection instruction includes device numbers of upper-level node devices and adjacent node devices at the same level that need to be connected.
[0031] In some embodiments, a node device is a device or computer connected to a network and capable of communicating with a server or other node devices. A node device can be any device such as a client, a router, a switch, etc. that can process data and exchange data with other devices.
[0032] In the present disclosure, the device numbers of the superior node device and the adjacent node device at the same level that need to be connected are determined by the server. Specifically, the node device can send a registration request to the server. After receiving the registration request sent by the node device, the server can first determine the device numbers of the superior node device and the adjacent node device at the same level that need to be connected to the node device, and use the device numbers to form a connection instruction and send it to the current node device. The connection instruction is used to guide the current node device how to establish a connection with other node devices (superior node devices and adjacent node devices at the same level).
[0033] In the present disclosure, a hierarchical relationship may exist between node devices. An upper-level node device refers to a node device that is at a higher level in logical or physical structure than the current node device. A same-level adjacent node device refers to a node device that is at the same level as the current node device and is adjacent in logical or physical structure. The device number is an identifier used to uniquely identify each node device in the network, which may be an IP address, MAC address, a custom ID number, etc. In the present disclosure, the device number of the current node device may be determined by the server in the order of the registration request time when the node device sends the registration request to the server. For the upper-level node device and the same-level adjacent node device that need to be connected, the server may determine the device number of the current node device.
[0034] Step 102: Establish connections with the upper node device and the same-level adjacent node device corresponding to the device number respectively, and obtain an initial peer-to-peer network based on the connection results. The number of node devices between the upper node device and the lower node device in the initial peer-to-peer network meets the preset ratio.
[0035] In some embodiments, after the current node device receives a connection instruction sent by the server, the node device can establish connections with the upper-level node device and the same-level adjacent node device respectively according to the device numbers of the upper-level node device and the same-level adjacent node device that need to be connected in the connection instruction, thereby obtaining an initial peer-to-peer network based on the connection results.
[0036] The lower-level node device refers to a node device at a lower level in the logical or physical structure of the current node device.
[0037] In the initial peer-to-peer network, the number of node devices between the upper node device and the lower node device needs to meet the preset ratio. The preset ratio can be determined according to the goals and requirements of the network design to ensure the stability and efficiency of the network. For example, in some cases, it is necessary to ensure that the number of lower node devices connected to each upper node device is within a certain range to avoid network congestion or data loss. In the present disclosure, the preset ratio is expressed as 1:N. N is a preset ratio factor in the preset ratio.
[0038] In the present disclosure, a peer-to-peer network is referred to as a P2P (Peer-to-Peer) network, which is a network architecture model that distributes tasks and workloads among peers. In a P2P network, each node (or peer) is equal in status, and there is no need for a central server or centralized management node to coordinate the transmission and processing of data. Instead, each node can communicate and exchange data directly with other nodes. The characteristics of a P2P network include decentralization, distributed resource storage and sharing, and scalability. Since there is no single central node, the entire network has stronger anti-attack and robustness. Even if some nodes fail or are attacked, other nodes can continue to work normally, ensuring the stability of the network and the availability of data.
[0039] It should be noted that in the peer-to-peer network of the present disclosure, since the node device is a currently registered node device, the node device can be connected to the first node device at the same level, so that the node devices at the same level are connected to each other in a ring to ensure horizontal sharing of data.
[0040] Step 103: Perform heartbeat communication detection on the upper node device and the adjacent node device at the same level, and update the initial peer-to-peer network according to the heartbeat communication detection result to obtain an updated peer-to-peer network, so as to realize data transmission between the node device and the server by using the updated peer-to-peer network.
[0041] In some embodiments, the present disclosure can perform heartbeat communication detection on upper-level node devices and adjacent node devices at the same level, and update the peer-to-peer network accordingly to achieve more efficient and reliable data transmission.
[0042] Heartbeat communication detection is a technology used to monitor the survival status and connection validity of network node devices. By sending heartbeat packets (also called heartbeat messages or keep-alive messages) regularly by the upper node device and the same-level adjacent node device, the current node device can confirm whether its connection with the upper node device and the same-level adjacent node device is still valid.
[0043] In the initial peer-to-peer network of the present disclosure, each node device is configured with a heartbeat detection mechanism. The mechanism can be sent regularly by the upper node device and the adjacent node device at the same level, or it can be actively initiated or passively received by the current node device. The heartbeat packet usually contains the identification information of the node device (such as device number, IP address, etc.), timestamp, etc. to ensure the accuracy and integrity of the data.
[0044] If no response is received from the superior node or the adjacent node at the same level within the specified time, it is considered that the node may have failed or the connection is disconnected, and the heartbeat communication detection result is determined to be a heartbeat abnormality.
[0045] In the present disclosure, the node device of the present disclosure can identify which nodes are still online and which nodes have failed or disconnected based on the heartbeat communication detection results, thereby updating the initial peer-to-peer network. The updated peer-to-peer network can include the latest node information and connection status. The node device sends the data packet to the target server or target node device based on the updated network topology and routing table, making the data transmission between the node device and the server more efficient and reliable.
[0046] In summary, the technical solution provided by the present invention receives a connection instruction sent by a server, wherein the connection instruction includes the device number of the superior node device and the adjacent node device of the same level to be connected; establishes connections with the superior node device and the adjacent node device of the same level corresponding to the device number respectively, and obtains an initial peer-to-peer network based on the connection result, wherein the number of node devices between the superior node device and the subordinate node device in the initial peer-to-peer network conforms to a preset ratio; performs heartbeat communication detection on the superior node device and the adjacent node device of the same level, and updates the initial peer-to-peer network based on the heartbeat communication detection result to obtain an updated updated peer-to-peer network, so as to utilize the updated peer-to-peer network to realize data transmission between the node device and the server, realize the construction of a hierarchical peer-to-peer network with disaster recovery capability, ensure that the node device utilizes heartbeat communication detection to ensure network stability, and at the same time reports data to the server step by step according to the hierarchical structure, effectively dispersing the pressure of data transmission, improving data reporting efficiency, and reducing the connection load of each node device, thereby providing strong support for realizing an educational information system with low load, high disaster recovery capability and high transmission efficiency.
[0047] As a possible implementation, Figure 2 The flowchart of another data transmission method shown in the figure, based on the above embodiment, obtains the specific process of the initial peer-to-peer network according to the connection result, including the following steps: Step 201: Establish connections with the upper-level node device and the same-level adjacent node device corresponding to the device number respectively to obtain a connection result.
[0048] Step 202: If the connection result is a connection failure, a connection failure message is fed back to the server, where the connection failure message includes the device number of the abnormal node device in the upper node device and the adjacent node devices at the same level.
[0049] In some embodiments, in certain application scenarios, the online stability of the node device cannot be absolutely guaranteed. Although the server will immediately trigger a change mechanism to restore its online status when it detects that the node is offline, due to delays and potential fluctuations in network transmission, the node may still be offline, resulting in connection failure. Connection failure means that the connection between the current node device and the upper node device or the adjacent node device at the same level cannot be established or maintained. This may be caused by network failure, device failure, configuration error, etc.
[0050] The abnormal node device refers to the upper node device or the same-level adjacent node device that causes the connection failure.
[0051] Step 203: receiving a connection update instruction sent by the server, where the connection update instruction includes a device number of a replacement node device corresponding to the abnormal node device.
[0052] In some embodiments, after the node device sends a connection failure message to the server, the server can query the node information of the registered online node device based on the device number of the abnormal node device in the connection failure message, determine the device number of the replacement node device corresponding to the abnormal node device, and based on the device number of the replacement node device corresponding to the abnormal node device, form an update connection instruction and send it to the node device.
[0053] Among them, the server determines the device number of the replacement node device corresponding to the abnormal node device, and can adopt a replacement strategy based on device type and priority, or a replacement strategy based on load balancing and fault recovery. The specific strategy can be designed according to actual conditions and is not limited in the present disclosed embodiment.
[0054] In an optional embodiment of the present disclosure, the present disclosure may adopt a replacement strategy based on device type and priority, as follows: The server can query the type of abnormal node device (such as sensor, smart device, etc.), and use the node information of the registered rewrite node device to determine a replacement node device of the same or compatible type. By comparing the device types, the server can ensure that the replacement node device can meet the requirements of the original abnormal node device in terms of function.
[0055] After finding multiple replacement node devices of the same or compatible type, the server can determine the best replacement node device based on a certain priority sorting strategy (such as device status, usage time, maintenance record, etc.). For example, the server can select the device with the best status, the shortest usage time, or the best maintenance record as the replacement node device. Once the best replacement node device is determined, the server will obtain the device number of the replacement node device and use it to generate an update connection instruction.
[0056] In an optional embodiment of the present disclosure, the present disclosure adopts a replacement strategy based on load balancing and fault recovery, which is as follows: The server can determine the replacement node device based on the load balancing of the entire system, that is, the server can choose a replacement node device with fewer connections or lighter load to balance the load of the entire system. At the same time, the server can also determine the replacement node device based on the needs of fault recovery. If the abnormal node device is a key device in the system, the server can choose a replacement node device with higher reliability and redundancy to ensure the stable operation of the system.
[0057] After determining the replacement node device, the server obtains the device number of the replacement node device and generates an update connection instruction.
[0058] Step 204: Based on the device number of the replacement node device in the update connection instruction, the connected abnormal node device is replaced with the replacement node device to obtain an initial peer-to-peer network.
[0059] In some embodiments, after receiving the update connection instruction sent by the server, the node device can parse the update connection instruction, disconnect from the abnormal node based on the device number of the replacement node device in the update connection instruction, and establish a connection with the replacement node device.
[0060] After the node device establishes a connection with the replacement node device, the node device may perform a connection check again to ensure that the connection with the replacement node device is valid and secure.
[0061] In the present disclosure, the node device may also notify other related nodes (eg, upper-level node devices and / or same-level adjacent node devices) of the information about establishing a connection with the replacement node device, so that they can also update their connection information.
[0062] After the above steps, all the node devices originally connected to the abnormal node device have established connections with the replacement node device, thereby forming a new initial peer-to-peer network that does not include the abnormal node device.
[0063] Step 205: If the connection result is successful, the node information of the upper-level node device and the adjacent node device at the same level is stored to obtain an initial peer-to-peer network, and the connection success information is fed back to the server.
[0064] In some embodiments, if the connection result is successful, the node information of the upper node device and the adjacent node devices of the same level of the node device is stored, and the successful connection information is fed back to the server to ensure that the server knows that the node device has successfully joined the network.
[0065] In the present disclosure, a node device may send node information and connection relationships of an upper-level node device and a same-level adjacent node device of the node device to a server, and the server stores the node information and connection relationships.
[0066] The node information and connection relationship stored in the server may specifically include the node identification (node ID), mac address, device group ID, node public network address, node LAN address, node number, upper node identification (parent node ID), same-level adjacent node identification (left node ID, right node ID), lower node identification (List<child node ID>), and status of the node device. The key data structure of the node information and connection relationship stored in the server is shown in Table 1.
[0067]
[0068] Table 1 Because node devices of the same level can be connected into a ring, and the ring of nodes of the same level is always reconnected into a ring with the newly registered node devices. Therefore, if the connection result is a successful connection, the node information of the upper-level node device and the adjacent node device of the same level is stored to obtain the initial peer-to-peer network, and the connection success information is fed back to the server. After that, the present disclosure may also include: when the node device is not the first node device of the same level, it is necessary to send a disconnection task to the adjacent node device of the same level (the adjacent left node of the same level). The disconnection task is used to instruct the adjacent node device of the same level to disconnect from the first node device in the hierarchy of the node device. Specifically, the present disclosure can first determine whether the node device is the first node device in the hierarchy of the node device based on the number of the node device. If it is not the first node device, a disconnection task is sent to the adjacent node of the same level on the left to ensure the correctness of the network structure and avoid unnecessary connections or loops.
[0069] The device number and the level of the node device are determined by the server and sent to the node device.
[0070] In summary, the present invention effectively handles the connection status when building the initial peer-to-peer network, stores relevant node information and notifies the server when successful, and finds a replacement node and re-establishes the connection with the assistance of the server when failed, thereby ensuring the integrity of the network structure and the effectiveness of the connection.
[0071] As a possible implementation, Figure 3 The flowchart of another data transmission method shown in the figure, based on the above embodiment, performs heartbeat communication detection on the upper node device and the adjacent node device of the same level, updates the initial peer-to-peer network according to the heartbeat communication detection result, and obtains the specific process of the updated peer-to-peer network after the update, including the following steps: Step 301: If a heartbeat abnormality is detected for a first node device among an upper-level node device and an adjacent node device at the same level, the heartbeat abnormality result of the first node device is sent to a server.
[0072] In some embodiments, the heartbeat abnormality result includes a device number of the first node device.
[0073] The node device maintains a connection heartbeat with its superior node device and adjacent node devices at the same level to perform heartbeat communication detection in real time and monitor the connection status of each other.
[0074] When a node device detects that the heartbeat of a node (such as the first node device) in its upper node device or adjacent node device of the same level is abnormal, it is considered that the node may be offline or the connection is unstable. The node device will immediately send the heartbeat abnormality result to the server so that the server can process it in time.
[0075] In an embodiment of the present disclosure, in order to reduce false alarms caused by network fluctuations, the present disclosure can also set an abnormal threshold on the server side. Only when the number of abnormal heartbeat results received by the server from the first node device is greater than or equal to the abnormal threshold, the first node device is determined to be offline.
[0076] Among them, the setting of the abnormal threshold needs to comprehensively consider multiple factors, including the preset ratio, the number of node devices, the stability of the network, the connection status of the node, etc., which are not limited in the embodiments of the present disclosure. Taking into account that the node device's adjacent node devices at the same level may also be offline, the abnormal threshold can be set to be less than N+3 (where N is the preset proportional factor in the preset ratio). At the same time, in order to cope with occasional offline reports caused by network fluctuations, the abnormal threshold can be set to be greater than 1 (unless there are special circumstances, such as the end node device is only connected to one node device). This ensures that when a single node device is temporarily offline due to network fluctuations, it will not cause the server to misjudge its offline status.
[0077] Through mechanisms such as heartbeat detection, abnormal reporting, and threshold setting, the server can effectively monitor the online status and connection health of node devices, reducing false positives and missed positives caused by network fluctuations.
[0078] Step 302: Receive a reconnection instruction sent by a substitute node device corresponding to the first node device, replace the connected first node device with the substitute node device, and obtain an updated peer-to-peer network. The reconnection instruction sent by the substitute node device is generated based on the replacement connection instruction sent by the server. The replacement connection instruction is used to instruct the substitute node device to replace the first node device.
[0079] In some embodiments, in order to quickly enable a healthy substitute node device to take over the work of the first node device when the first node device cannot work normally, the server of the present disclosure can query the node information of the registered online node device according to the device number of the first node device in the heartbeat abnormality result after receiving the heartbeat abnormality result sent by the node device, determine the device number of the substitute node device corresponding to the first node device, and form a replacement connection instruction based on the device number of the substitute node device corresponding to the first node device, and send it to the substitute node device. The substitute node device can generate a reconnection instruction based on the connection strategy and send it to the node device, so that the node device replaces the connected first node device with the substitute node device, thereby obtaining an updated peer-to-peer network.
[0080] Since the present disclosure can set an abnormality threshold on the server side, the server of the present disclosure can query the node information of the registered online node device according to the device number of the first node device in the heartbeat abnormality result when the heartbeat abnormality result of the first node device received from the node device is greater than or equal to the abnormality threshold, determine the device number of the substitute node device corresponding to the first node device, and based on the device number of the substitute node device corresponding to the first node device, form a replacement connection instruction and send it to the substitute node device. The substitute node device can generate a reconnection instruction based on the connection strategy and send it to the node device, so that the node device replaces the connected first node device with the substitute node device, thereby obtaining an updated peer network.
[0081] Among them, the way in which the server determines the device number of the substitute node device corresponding to the first node device in the present disclosure and the way in which the server determines the device number of the replacement node device corresponding to the abnormal node device in the above step 203 can be the same or different, and the specific selection is based on the actual situation and is not limited in the embodiments of the present disclosure. In addition, in order to ensure that the change to the original connection is minimal, the substitute node device of the present disclosure can also be pre-set, that is, the node device with the last device number in each initial peer-to-peer network is set as the substitute node device.
[0082] It should be noted that because the server cannot directly contact the node device with which the connection has not been established, when the server sends the replacement connection instruction, it can be sent down step by step through the network structure of the initial peer-to-peer network until the replacement node device is notified. That is, the replacement node device receives the replacement connection instruction sent by the server layer by layer according to the network architecture of the initial peer-to-peer network.
[0083] In some embodiments, since the first node device is any one of the superior node device or the adjacent node device of the same level of the node device, after the substitute node device receives the replacement connection instruction corresponding to the first node device sent by the server, it can connect to the superior node device and the adjacent node device of the same level that were previously connected to the first node device according to the replacement connection instruction and the connection strategy, share data, and realize that the node device replaces the first node device with the substitute node device.
[0084] In the replacement connection process, the connection strategy of the substitute node device can be determined according to the result of judging whether it is the first node device at the same level as the first node device. The connection strategy can include a first connection strategy and a second connection strategy.
[0085] Specifically, the substitute node device determines whether the substitute node device is the first node device at the same level as the first node device. If not, the first connection strategy is obtained, that is, notifying the left side of the same level adjacent node device connected to the first node device to directly connect to the right side of the same level adjacent node device (so that the node devices at the same level are reconnected into a ring), and disconnecting the left side of the same level adjacent node device directly connected to the right side of the same level adjacent node device, and disconnecting the upper level node device connected to the first node device. If yes, the second connection strategy is obtained, that is, disconnecting the upper level node device connected to the first node device. After the substitute node obtains the connection strategy, it can send a reconnection instruction to the node device based on the connection strategy.
[0086] After the replacement node device establishes a new connection with the upper-level node device and the adjacent node device at the same level, it can also send replacement completion information to the server to notify that the network update has been completed.
[0087] It should be noted that in the present disclosure, heartbeat communication detection is performed on the upper-level node device and the adjacent node device at the same level, and the initial peer network is updated based on the heartbeat communication detection result to obtain an updated peer network. After that, the present disclosure may also include: sending the transmission data to the upper-level node device and the adjacent node device at the same level corresponding to the updated peer network respectively, so as to use the upper-level node device and the adjacent node device at the same level to send the transmission data to the first-level node device, the first-level node device is directly connected to the server, and the first-level node device is used to send the received transmission data to the server.
[0088] The first-level node device is responsible for receiving the transmission data from the lower-level node devices and sending it to the server. The transmission data is passed upward step by step in the updated peer-to-peer network. When the data reaches the first-level node device, the first-level node device sends it to the server. The server receives and processes the data, completing the entire data transmission process.
[0089] Among them, in order to reduce the concurrency pressure of the server, for data with low timeliness requirements, the present disclosure can set a time interval threshold. When the first-level node device receives the transmission data, it reports the transmission data within the current time interval to the server in batches according to the time interval threshold.
[0090] Since the number of first-level node devices is small and they play a key role in reporting to the server, in order to ensure disaster recovery, the first-level node devices disclosed in the present invention can share transmission data with all other first-level nodes in the updated peer-to-peer network. When the first-level node device originally holding the transmission data is accidentally offline, the transmission data can be reported to the server by other first-level node devices disclosed in the present invention.
[0091] The first-level node device can also negotiate with all other first-level node devices in the updated peer-to-peer network to determine the target first-level node device for reporting the transmission data to the server. That is, the first-level node devices can share their respective load scores as a basis for decision-making through two-to-two communication, and use the same decision-making algorithm to negotiate and select the first-level node with the lowest load as the target node, which is responsible for reporting the data transmission to the server to avoid duplicate reporting and reduce the network burden. Among them, the calculation method responsible for the score can be set according to actual conditions and needs, and is not limited in the present embodiment.
[0092] The first-level node device can wait for the successful receipt of the target first-level node device used to report the transmission data. That is, because the negotiated target first-level node device may still be accidentally offline, other first-level node devices can set a timeout for waiting for the receipt. If the successful receipt is not fed back within the specified timeout, the other first-level node devices believe that the target first-level node device has failed to report. Therefore, the other first-level node devices can renegotiate the reported target first-level node device in the above manner and report the transmission data to the server again.
[0093] In order to save the repeated overhead of node device data transmission, under the premise of ensuring disaster recovery requirements, the present disclosure can set a routing threshold for the number of horizontal routings between node devices at the same level. When the routing threshold is reached, data transmission is no longer performed. In the process of forwarding from the lower node device to the upper node device, only the number of routings is judged, and the number of routings does not increase after data transmission, because the forwarding from the lower node device to the upper node device is the only way to ensure that the data reaches the server. If the number of routings is increased here, the disaster recovery effect of the horizontal data forwarding originally designed for disaster recovery will be lost, wasting the data transmission cost brought by the horizontal data forwarding. In other words, if the number of routings between the upper node device is less than the preset routing threshold, and the transmission data is not historical transmission data, the transmission data will be sent to the upper node device. If the number of routings between the adjacent node devices at the same level is less than the preset routing threshold, and the transmission data is not historical transmission data, the routing number will be updated and the transmission data will be sent to the adjacent node devices at the same level.
[0094] The routing threshold can be set according to the actual network scale and complexity to avoid infinite circulation or excessive diffusion of data in the network, which is not limited in the embodiments of the present disclosure.
[0095] Historical transmission data is transmission data that has been forwarded by a node device before. Each batch of transmission data carries a unique data identifier to ensure that when data is forwarded through multiple node devices, even if the same node device receives the same batch of data from different routes, it can be judged and repeated forwarding can be avoided by checking the data identifier. The present disclosure can determine whether the transmission data is historical transmission data by checking the data identifier of the transmission data.
[0096] In summary, the present disclosure timely detects and handles the heartbeat anomalies of nodes in the network through the heartbeat communication detection mechanism to ensure network stability. When a heartbeat anomaly is detected in a node of the upper node or the adjacent node of the same level, the abnormal result will be immediately reported to the server, and the process of replacing the abnormal node with a substitute node will be triggered, so as to quickly restore the network structure and obtain an updated peer-to-peer network. On this basis, the present disclosure also realizes the reliable transmission of data, that is, according to the number of routing times and the newness of the data, the transmission data is sent to the upper node device and the adjacent node device of the same level, and finally the data is reported to the server through the first-level node device. Not only the efficiency and accuracy of data transmission are improved, but also the problems of network congestion and repeated data transmission are effectively avoided, ensuring the robustness and reliability of the entire peer-to-peer network.
[0097] Figure 4 The following is a flow chart of a data transmission method provided by an embodiment of the present disclosure. Figure 4 As shown, the method is applied to a server, and the method includes: Step 401: Determine the device number of the node device according to the registration request time of the node device.
[0098] In some embodiments, when the server receives a registration request from a node device, it records the requested registration time of the request. Subsequently, the server will number the node devices according to the order of the requested registration times to obtain the device number of the node device. Specifically, the server will number them one by one from small to large according to the early or late registration time. In this way, the earliest registered node device will obtain the smallest number, and the latest registered node device will obtain the largest number, so that the server can ensure that each node device has a unique and ordered device number, which helps the server better manage and maintain the node devices in the peer-to-peer network.
[0099] Step 402: According to the device number of the node device, determine the device numbers of the upper-level node device and the same-level adjacent node devices that need to be connected to the node device.
[0100] In some embodiments, the server may select different number determination strategies based on the size relationship between the device number of the node device and a preset proportional factor in a preset proportion to determine the device numbers of the upper-level node device and the same-level adjacent node device that need to be connected to the node device.
[0101] Step 403: a connection instruction is formed according to the device number, and the connection instruction is sent to the node device. The connection instruction includes the device numbers of the upper node device and the adjacent node devices at the same level that need to be connected to the node device.
[0102] In some embodiments, after obtaining the device numbers of the upper node device and the same-level adjacent node device that need to be connected to the node device, the server can generate a connection instruction and send the connection instruction to the node device to instruct the node device to connect to the selected upper node device and the same-level adjacent node device.
[0103] In summary, the technical solution provided by the present invention determines the device number of the node device according to the request registration time of the node device; determines the device numbers of the superior node device and the adjacent node devices at the same level that need to be connected to the node device according to the device number of the node device; forms a connection instruction according to the device number, and sends the connection instruction to the node device, wherein the connection instruction includes the device numbers of the superior node device and the adjacent node devices at the same level that need to be connected to the node device, thereby building a hierarchical peer-to-peer network, enabling the node devices to report data to the server step by step according to the hierarchical structure, effectively dispersing the data transmission pressure, improving the data reporting efficiency, and reducing the connection load of each node device, thereby providing strong support for the realization of an educational information system with low load, high disaster recovery capability and high transmission efficiency.
[0104] As a possible implementation, Figure 5 The flowchart of another data transmission method shown in the figure, based on the above embodiment, determines the specific process of the device number of the upper node device and the same-level adjacent node device that need to be connected to the node device according to the device number of the node device, including the following steps: Step 501 , according to the size of the preset scale factor corresponding to the device number of the node device and the preset scale, determine the device numbers of the upper node device and the same-level adjacent node device to be connected to the node device.
[0105] Step 502: If the device number of the node device is less than or equal to the preset proportional factor corresponding to the preset ratio, the device numbers of the upper-level node device and the same-level adjacent node devices that need to be connected to the node device are determined based on the node device list. The preset proportional factor is used to adjust the number of node devices between the upper-level node device and the lower-level node device to meet the preset ratio.
[0106] In some embodiments, each node device has a unique device number. The present disclosure determines whether the device number of the node device is less than or equal to a preset scale factor corresponding to a preset scale.
[0107] If the device number of the node device is less than or equal to the preset scale factor (P≤N) corresponding to the preset scale, the stored node device list (List <node>) to determine the device numbers of the upper-level node devices and the adjacent node devices at the same level that need to be connected to the node device.
[0108] The node information of each node device in the node device list may include the device number, location, level, etc. of the node device. The node device list may also include server information of the server.
[0109] Step 503: If the device number of the node device is greater than the preset proportional factor, the device numbers of the upper node device and the same-level adjacent node devices that need to be connected to the node device are determined according to the device number of the node device and the preset proportional factor.
[0110] In some embodiments, if the device number of a node device is greater than a preset scaling factor (P>N), the hierarchy of the node device is determined based on the device number of the node device and the preset scaling factor; the first device number of the first node device in the hierarchy is determined based on the hierarchy of the node device and the preset scaling factor; the device number of an upper-level node device corresponding to the node device is determined based on the first device number, the device number of the node device and the preset scaling factor; and the device number of an adjacent node device of the same level corresponding to the node device is determined based on the device number of the node device and the preset scaling factor.
[0111] In an optional embodiment of the present disclosure, the present disclosure may determine the level of the node device according to the device number of the node device and a preset scale factor according to the following formula 1: Formula 1 Where L is the level of the node device, P is the device number of the node device, and N is the preset scaling factor. To round down; According to the following formula 2, the first device number in the hierarchy is determined according to the hierarchy of the node device and the preset scale factor: Formula 2 in, is the first device number of the first node device in the hierarchy of node devices, N is a preset scale factor, and L is the hierarchy of the node device; pass , it can be determined that the parent node of the node device is the first node in the previous level Node device.
[0112] Based on the above content, the present disclosure can determine the device number of the upper node device corresponding to the node device according to the following formula 3, based on the first device number, the device number of the node device, and the preset proportional factor: Formula 3 in, is the device number of the upper node device corresponding to the node device, and P is the device number of the node device. is the first device number of the first node device in the hierarchy of node devices, N is a preset scale factor, and L is the hierarchy of the node device.
[0113] In an optional embodiment of the present disclosure, the device number of the adjacent node device at the same level corresponding to the node device is determined based on the device number of the node device and a preset proportional factor, which may specifically include: judging whether the node device is the first node device in its hierarchy, and based on the judgment result, determining the device number of the adjacent node device at the same level corresponding to the node device based on the device number of the node device and a preset proportional factor.
[0114] If the node device is the first node device in the hierarchy (i.e. ), it is determined that the node device does not have any adjacent node devices at the same level. In other words, because the node device is the first node device in the hierarchy, the node device does not have any adjacent node devices at the same level on the left, and the node device is the node device currently requesting registration, which is the last node device, and its adjacent node device at the same level on the right is the next node device to register with the server, so there is no adjacent node device at the same level on the right at present.
[0115] If the node device is not the first node device in the hierarchy, determine the device number of the node device on the left side of the node device. .in, is the device number of the node device on the left side of the node device, and P is the device number of the node device. Determine the device number of the node device on the right side of the node device as the first node device in the hierarchy. ,in, The device number of the node device on the left side of the node device. is the first device number of the first node device in the hierarchy of node devices, N is a preset scale factor, and L is the hierarchy of the node device.
[0116] It can be understood that since the node device is the node device that currently sends a registration request to the server and is the last node device in the current network, its subordinate node device is the node device that subsequently sends a registration request to the server. Therefore, the node device currently has no subordinate node device. After other node devices subsequently send registration requests to the server, the node device may be connected as the superior node device of these node devices.
[0117] In summary, the present disclosure can flexibly determine the device numbers of the upper node and the adjacent nodes at the same level that the node device needs to connect to by comparing the device number of the node device with the preset proportional factor. When the node device number is less than or equal to the preset proportional factor, it is directly searched through the node device list; and when the node device number is greater than the preset proportional factor, the node device level and the first node number in the level are determined by calculation, and then the device numbers of the upper node and the adjacent nodes at the same level are calculated. The logic and accuracy of the connection between node devices are ensured, and at the same time, the distribution of node devices can be adjusted according to the preset proportional factor to meet specific proportional requirements.
[0118] based on Figures 1 to 5 The embodiment shown, as Figure 6 As shown, the present disclosure provides a specific schematic diagram of the network architecture of a peer-to-peer network.
[0119] In this disclosure, reference is made to Figure 6 , Figure 6 It includes servers (SERVER) and node devices, where the numbered circles are each node device, and the numbers in the circles are the device numbers of each node device. This network architecture can adopt the way of step-by-step jurisdiction and step-by-step data reporting between node devices, and the preset ratio between the upper node device and the lower node device is met (that is, it supports configurable parent-child jurisdiction ratio (such as 1:N)). By increasing the preset proportional factor N value, the hierarchy can be shortened and the data reporting efficiency can be improved, but at the same time, the connection load of a single node will increase. Therefore, the preset proportional factor can be set according to actual needs. Figure 6 This is just an example. Node devices at the same level can share data horizontally and connect to form a ring, thus achieving fast data transmission and sharing.
[0120] In the present disclosure, the network architecture can also have the characteristics of high availability and low connection load. Adjacent node devices at the same level can be distributed and connected to different upper node devices, which enhances disaster recovery capabilities. When an upper node device fails, the lower node device connected to it can report data through the adjacent node device at the same level, adding only one route, ensuring the continuity and stability of the data. In addition, considering the disaster recovery effect, in the present disclosure, each node device establishes a maximum of N+3 connections (N is a preset proportional factor).
[0121] In summary, compared with the traditional P2P network, the disclosed peer-to-peer network greatly reduces the load pressure of single-node devices and is particularly suitable for low-performance node devices, such as electronic class signs.
[0122] Corresponding to the above-mentioned data transmission method, the present invention also proposes a data transmission device applied to the node device side and a data transmission device applied to the server side. Since the device embodiment of the present invention corresponds to the above-mentioned method embodiment, the details not disclosed in the device embodiment can be referred to the above-mentioned method embodiment, and will not be repeated in the present invention.
[0123] Figure 7 A schematic diagram of a data transmission device provided in an embodiment of the present disclosure is shown in FIG. Figure 7 As shown, the device is applied to a node device and includes: The receiving unit 710 is used to receive a connection instruction sent by the server, where the connection instruction includes the device numbers of the upper-level node device and the adjacent node device at the same level to be connected; The construction unit 720 is used to establish connections with the upper node device and the same-level adjacent node device corresponding to the device number, and obtain an initial peer-to-peer network according to the connection result, wherein the number of node devices between the upper node device and the lower node device in the initial peer-to-peer network meets a preset ratio; The updating unit 730 is used to perform heartbeat communication detection on the upper node device and the adjacent node device at the same level, and update the initial peer-to-peer network according to the heartbeat communication detection result to obtain an updated peer-to-peer network, so as to realize data transmission between the node device and the server by using the updated peer-to-peer network.
[0124] In some embodiments of the present disclosure, the construction unit 720 is used to: if the connection result is a connection failure, feedback connection failure information to the server, the connection failure information including the device number of the abnormal node device in the upper node device and the adjacent node devices at the same level; receive an update connection instruction sent by the server, the update connection instruction including the device number of the replacement node device corresponding to the abnormal node device; based on the device number of the replacement node device in the update connection instruction, replace the connected abnormal node device with the replacement node device to obtain an initial peer-to-peer network; if the connection result is a successful connection, store the node information of the upper node device and the adjacent node device at the same level to obtain the initial peer-to-peer network, and feedback connection success information to the server.
[0125] In some embodiments of the present disclosure, the construction unit 720 is also used to: if the connection result is a successful connection, store the node information of the upper node device and the same-level adjacent node device, obtain the initial peer network, and feedback the connection success information to the server, and then send a disconnection task to the same-level adjacent node device, and the disconnection task is used to instruct the same-level adjacent node device to disconnect from the first node device in the hierarchy of the node device.
[0126] In some embodiments of the present disclosure, the update unit 730 is used to: if a heartbeat abnormality is detected in a first node device among an upper-level node device and an adjacent node device at the same level, send the heartbeat abnormality result of the first node device to a server; receive a reconnection instruction sent by a substitute node device corresponding to the first node device, replace the connected first node device with the substitute node device, and obtain an updated peer network, wherein the reconnection instruction sent by the substitute node device is generated based on the replacement connection instruction sent by the server, and the replacement connection instruction is used to instruct the substitute node device to replace the first node device.
[0127] In some embodiments of the present disclosure, the device also includes: a data transmission unit, which is used to perform heartbeat communication detection on the upper-level node device and the same-level adjacent node device, and update the initial peer network based on the heartbeat communication detection result to obtain an updated updated peer network. Thereafter, the transmission data is sent to the upper-level node device and the same-level adjacent node device corresponding to the updated peer network respectively, so as to use the upper-level node device and the same-level adjacent node device to send the transmission data to the first-level node device, the first-level node device is directly connected to the server, and the first-level node device is used to send the received transmission data to the server.
[0128] In some embodiments of the present disclosure, the data transmission unit is used to: if the number of routing times between an upper-level node device is less than a preset routing threshold and the transmission data is not historical transmission data, then the transmission data is sent to the upper-level node device; if the number of routing times between an adjacent node device at the same level is less than a preset routing threshold and the transmission data is not historical transmission data, then the routing times is updated and the transmission data is sent to the adjacent node device at the same level.
[0129] Figure 8 A schematic diagram of a data transmission device provided in an embodiment of the present disclosure is shown in FIG. Figure 8 As shown, the device is applied to a server, and the device includes: A first determining unit 810 is used to determine a device number of a node device according to a registration request time of the node device; The second determining unit 820 is used to determine the device numbers of the upper-level node device and the same-level adjacent node device that need to be connected to the node device according to the device number of the node device; The sending unit 830 is used to form a connection instruction according to the device number and send the connection instruction to the node device. The connection instruction includes the device numbers of the upper node device and the same-level adjacent node devices that need to be connected to the node device.
[0130] In some embodiments of the present disclosure, the second determination unit 820 is used to: if the device number of the node device is less than or equal to the preset proportional factor corresponding to the preset ratio, then determine the device numbers of the upper node device and the same-level adjacent node devices that need to be connected to the node device based on the node device list, and the preset proportional factor is used to adjust the number of node devices between the upper node device and the lower node device to meet the preset ratio; if the device number of the node device is greater than the preset proportional factor, then determine the device numbers of the upper node device and the same-level adjacent node devices that need to be connected to the node device based on the device number of the node device and the preset proportional factor.
[0131] In some embodiments of the present disclosure, the second determination unit 820 is used to: determine the hierarchy of the node device based on the device number of the node device and a preset proportional factor; determine the first device number of the first node device in the hierarchy based on the hierarchy of the node device and the preset proportional factor; determine the device number of the upper-level node device corresponding to the node device based on the first device number, the device number of the node device and the preset proportional factor; determine the device number of the adjacent node device of the same level corresponding to the node device based on the device number of the node device and the preset proportional factor.
[0132] In some embodiments of the present disclosure, the second determining unit 820 is configured to: According to the following formula 1, the level of the node device is determined according to the device number of the node device and the preset scale factor: Formula 1 Wherein, L is the level of the node device, P is the device number of the node device, and N is the preset scaling factor; According to the following formula 2, the first device number in the hierarchy is determined according to the hierarchy of the node device and the preset scale factor: Formula 2 in, is the first device number of the first node device in the hierarchy of node devices, N is a preset scale factor, and L is the hierarchy of the node device; According to the following formula 3, the device number of the upper-level node device corresponding to the node device is determined according to the first device number, the device number of the node device, and the preset proportional factor: Formula 3 in, is the device number of the upper node device corresponding to the node device, and P is the device number of the node device. is the first device number of the first node device in the hierarchy of node devices, N is a preset scale factor, and L is the hierarchy of the node device.
[0133] It should be noted that the above explanation of the method embodiment is also applicable to the device of this embodiment, and the principle is the same, which is not limited in this embodiment.
[0134] Based on the above Figures 1 to 5 The method shown in the figure, accordingly, this embodiment also provides a computer program product, including a computer program, which implements the above-mentioned Figures 1 to 5 The method shown.
[0135] Based on the above Figures 1 to 5 The method shown in the embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Figures 1 to 5 The method shown.
[0136] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.
[0137] like Fig. 9 The figure shows a hardware structure diagram of an electronic device of the present invention, including: at least one processor 901; and, A memory 902 that is communicatively connected to at least one of the processors 901; wherein: The memory 902 stores instructions that can be executed by at least one of the processors. The instructions are executed by at least one of the processors to enable the at least one of the processors to perform the data transmission method as described above.
[0138] Fig. 9 A processor 901 is taken as an example.
[0139] The electronic device may further include: an input device 903 and a display device 904 .
[0140] The processor 901, the memory 902, the input device 903 and the display device 904 may be connected via a bus or other means, and the figure takes the connection via a bus as an example.
[0141] The memory 902 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules corresponding to the review content generation method in the embodiment of the present application, for example, Figures 1 to 5 The processor 901 executes various functional applications and data processing by running the non-volatile software programs, instructions and modules stored in the memory 902, that is, implements the data transmission method in the above embodiment.
[0142] The memory 902 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the review content generation method, etc. In addition, the memory 902 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 902 may optionally include a memory remotely arranged relative to the processor 901, and these remote memories may be connected to the device for executing the review content generation method 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.
[0143] The input device 903 can receive user clicks and generate signal inputs related to user settings and function controls of the review content generation method. The display device 904 can include display devices such as a display screen.
[0144] The one or more modules are stored in the memory 902, and when executed by the one or more processors 901, the data transmission method in any of the above method embodiments is executed.
[0145] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0146] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.
[0147] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.
[0148] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware. By applying the scheme of this embodiment, compared with the current existing technology, this embodiment receives a connection instruction sent by a server, and the connection instruction includes the device number of the upper node device and the adjacent node device of the same level that need to be connected; establishes connections with the upper node device and the adjacent node device of the same level corresponding to the device number, and obtains an initial peer-to-peer network based on the connection result, and the number of node devices between the upper node device and the lower node device in the initial peer-to-peer network meets the preset ratio; performs heartbeat communication detection on the upper node device and the adjacent node device of the same level, and updates the initial peer-to-peer network based on the heartbeat communication detection result to obtain an updated updated peer-to-peer network, so as to realize data transmission between the node device and the server by using the updated peer-to-peer network, realize the construction of a hierarchical peer-to-peer network with disaster recovery capability, ensure that the node device uses heartbeat communication detection to ensure network stability, and at the same time report data to the server step by step according to the hierarchical structure, effectively disperse the data transmission pressure, improve data reporting efficiency, and reduce the connection load of each node device, so as to provide strong support for realizing an educational information system with low load, high disaster recovery capability and high transmission efficiency.
[0149] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "includes a..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0150] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.< / node>
Claims
1. A data transmission method, characterized in that: The method is applied to a node device, and the method comprises: Receive a connection instruction sent by a server, wherein the connection instruction includes device numbers of an upper-level node device and a same-level adjacent node device to be connected; Establishing connections with the upper-level node device and the same-level adjacent node device corresponding to the device number respectively, and obtaining an initial peer-to-peer network according to the connection results, wherein the number of node devices between the upper-level node device and the lower-level node device in the initial peer-to-peer network meets a preset ratio; Heartbeat communication detection is performed on the upper-level node device and the adjacent node device at the same level. According to the heartbeat communication detection result, the initial peer-to-peer network is updated to obtain an updated peer-to-peer network, so as to realize data transmission between the node device and the server by using the updated peer-to-peer network.
2. The method according to claim 1, characterized in that The obtaining of the initial peer-to-peer network according to the connection result comprises: If the connection result is a connection failure, feeding back connection failure information to the server, wherein the connection failure information includes a device number of an abnormal node device among the upper-level node device and the adjacent node devices at the same level; receiving an update connection instruction sent by the server, wherein the update connection instruction includes a device number of a replacement node device corresponding to the abnormal node device; Based on the device number of the replacement node device in the update connection instruction, the connected abnormal node device is replaced with the replacement node device to obtain an initial peer-to-peer network; If the connection result is a successful connection, the node information of the upper-level node device and the adjacent node device at the same level is stored to obtain an initial peer-to-peer network, and the connection success information is fed back to the server.
3. The method according to claim 2, characterized in that If the connection result is a successful connection, the node information of the upper node device and the adjacent node device at the same level is stored to obtain an initial peer-to-peer network, and the connection success information is fed back to the server. After that, the method includes: A disconnection task is sent to the adjacent node device at the same level, where the disconnection task is used to instruct the adjacent node device at the same level to disconnect from the first node device in the hierarchy of the node device.
4. The method according to claim 1, characterized in that: The performing of heartbeat communication detection on the upper node device and the adjacent node device at the same level, and updating the initial peer-to-peer network according to the heartbeat communication detection result to obtain the updated peer-to-peer network includes: If a heartbeat abnormality is detected for a first node device among the upper-level node device and the adjacent node devices at the same level, the heartbeat abnormality result of the first node device is sent to the server; Receive a reconnection instruction sent by a substitute node device corresponding to the first node device, replace the connected first node device with the substitute node device, and obtain an updated peer-to-peer network, wherein the reconnection instruction sent by the substitute node device is generated based on the replacement connection instruction sent by the server, and the replacement connection instruction is used to instruct the substitute node device to replace the first node device.
5. The method according to claim 1, characterized in that The method further comprises: performing heartbeat communication detection on the upper node device and the adjacent node device at the same level, and updating the initial peer-to-peer network according to the heartbeat communication detection result to obtain an updated peer-to-peer network. The transmission data is sent respectively to the upper node device and the same-level adjacent node device corresponding to the updated peer network, so that the upper node device and the same-level adjacent node device are used to send the transmission data to the first-level node device. The first-level node device is directly connected to the server, and the first-level node device is used to send the received transmission data to the server.
6. The method according to claim 5, characterized in that The step of sending the transmission data to the upper-level node device and the same-level adjacent node device corresponding to the updated peer-to-peer network includes: If the number of routing times between the upper node device and the upper node device is less than a preset routing threshold, and the transmission data is not historical transmission data, the transmission data is sent to the upper node device. If the number of routing times between the adjacent node device at the same level is less than a preset routing threshold, and the transmission data is not historical transmission data, the routing times are updated, and the transmission data is sent to the adjacent node device at the same level.
7. A data transmission method, characterized in that: The method is applied to a server, and the method comprises: Determining the device number of the node device according to the registration request time of the node device; Determine, according to the device number of the node device, the device numbers of the upper-level node device and the same-level adjacent node device to be connected to the node device; A connection instruction is formed according to the device number and sent to the node device. The connection instruction includes the device numbers of the upper-level node device and the same-level adjacent node device that need to be connected to the node device.
8. The method according to claim 7, characterized in that The determining, based on the device number of the node device, the device numbers of the upper-level node device and the same-level adjacent node device that need to be connected to the node device includes: If the device number of the node device is less than or equal to the preset proportional factor corresponding to the preset proportion, the device numbers of the upper node device and the same-level adjacent node devices that need to be connected to the node device are determined according to the node device list, and the preset proportional factor is used to adjust the number of node devices between the upper node device and the lower node device to meet the preset proportion; If the device number of the node device is greater than the preset proportional factor, the device numbers of the upper-level node device and the same-level adjacent node devices that need to be connected to the node device are determined according to the device number of the node device and the preset proportional factor.
9. The method according to claim 8, characterized in that The determining, based on the device number of the node device and the preset proportional factor, the device numbers of the upper-level node device and the same-level adjacent node device that need to be connected to the node device includes: Determining the level of the node device according to the device number of the node device and the preset scale factor; Determining a first device number of a first node device in the hierarchy according to the hierarchy of the node device and the preset scaling factor; Determine the device number of the upper-level node device corresponding to the node device according to the first device number, the device number of the node device and the preset proportional factor; The device number of the adjacent node device at the same level corresponding to the node device is determined according to the device number of the node device and a preset proportional factor.
10. The method according to claim 9, characterized in that The determining the level of the node device according to the device number of the node device and the preset scale factor includes: According to the following formula 1, the level of the node device is determined according to the device number of the node device and the preset scale factor: Formula 1 Wherein, L is the level of the node device, P is the device number of the node device, and N is the preset scaling factor; According to the following formula 2, the first device number in the hierarchy is determined according to the hierarchy of the node device and the preset proportional factor: Formula 2 in, is the first device number of the first node device in the hierarchy of the node devices, N is a preset scale factor, and L is the hierarchy of the node device; According to the following formula 3, the device number of the upper-level node device corresponding to the node device is determined according to the first device number, the device number of the node device, and the preset proportional factor: Formula 3 in, is the device number of the upper node device corresponding to the node device, P is the device number of the node device, is the first device number of the first node device in the hierarchy of the node devices, N is a preset scale factor, and L is the hierarchy of the node device.
11. A data transmission device, characterized in that: The device is applied to a node device, and the device includes: A receiving unit, configured to receive a connection instruction sent by a server, wherein the connection instruction includes device numbers of an upper-level node device and an adjacent node device at the same level to be connected; A construction unit, used to establish connections with the upper node device and the same-level adjacent node device corresponding to the device number, respectively, and obtain an initial peer-to-peer network according to the connection result, wherein the number of node devices between the upper node device and the lower node device in the initial peer-to-peer network meets a preset ratio; The updating unit is used to perform heartbeat communication detection on the upper-level node device and the adjacent node device at the same level, and update the initial peer-to-peer network according to the heartbeat communication detection result to obtain an updated peer-to-peer network, so as to use the updated peer-to-peer network to realize data transmission between the node device and the server.
12. A data transmission device, characterized in that: The device is applied to a server, and comprises: A first determining unit, configured to determine a device number of the node device according to a registration request time of the node device; A second determining unit is used to determine the device numbers of the upper-level node device and the same-level adjacent node device that need to be connected to the node device according to the device number of the node device; The sending unit is used to form a connection instruction according to the device number and send the connection instruction to the node device, wherein the connection instruction includes the device numbers of the upper-level node device and the same-level adjacent node device that need to be connected to the node device.
13. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method of any one of claims 1 to 6 or claims 7 to 10 is implemented.
14. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method of any one of claims 1 to 6 or claims 7 to 10.
Citation Information
Patent Citations
Video data processing method and system
CN110855931A
Method for improving power utilization information acquisition success rate
CN114584274A
Data transmission method and system, electronic equipment and storage medium
CN116633967A
Method and device for quickly identifying topological structure of power distribution network
CN117390801A
Method for managing topological relation between nodes
CN118055029A
