Equipment connection management method and system, storage medium and electronic equipment
By generating heartbeat collection packets to detect and sorting communication links, the problem of inefficient connections in the prior art is solved, and efficient and high-quality communication of device connections is achieved.
Patent Information
- Application Number
- CN202510413313.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-07-18
AI Technical Summary
In the existing equipment connection management system, the connection efficiency is inefficient and the ability to intelligently select the best communication link for connection is not possible.
By generating and sending a heartbeat collection packet, detecting the response time of multiple communication links, sorting based on preset priority rules and response times, and switching to the link with the best communication quality for connection.
Improves the efficiency and stability of device connections, ensuring that client devices and server devices can quickly establish and maintain high-quality communication connections.
Smart Images

Figure CN120343073A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network communication technologies, and in particular, to a device connection management method and system, a storage medium, and an electronic device. Background Art
[0002] In existing device connection management systems, the heartbeat rule is designed in a serial attempt manner. The system will re-attempt the heartbeat step by step according to a predetermined connection process until the heartbeat is successfully passed and the connection is completed. This serial attempt method can ensure that the connection process proceeds in a predetermined order, gradually eliminating possible problems until the connection is successfully established.
[0003] Although this design can meet the basic connection management requirements, it makes the connection mechanism usually linear, that is, the system will attempt to connect in a fixed order and interval, which will lead to low connection efficiency. Especially in the case of a large number of devices or a complex network environment, this method cannot intelligently select the best communication link for connection. Summary of the Invention
[0004] Embodiments of the present invention provide a device connection management method and system, a storage medium, and an electronic device to solve the problems of low connection efficiency and inability to select the best communication link for connection in the prior art.
[0005] The present invention discloses a device connection management method applied to a client device, and the client device and a server device can establish a connection through multiple communication links with different connection methods;
[0006] The device connection management method includes:
[0007] Obtain the connection information of the server device, and establish a connection with the server device based on the connection information, where the connection information includes the communication link;
[0008] Generate a first heartbeat set packet including a plurality of first heartbeat requests, and each communication link corresponds to at least one of the first heartbeat requests;
[0009] Send the first heartbeat set packet, and receive at least one first response message. Take the communication link corresponding to each first response message as a first candidate link, and obtain the response time of each first candidate link according to the reception time of each first response message;
[0010] Perform priority sorting on the first candidate links based on a preset priority rule and the response time, and take the first candidate link ranked first as the first target link;
[0011] Determine whether the priority of the currently adopted communication link is lower than that of the first target link. If not, switch to the first target link for connection.
[0012] Optionally, the device connection management method further includes:
[0013] Obtain the current communication quality information, and determine whether to switch the communication link based on the current communication quality information;
[0014] If so, generate and send a second heartbeat collection packet, where the second heartbeat collection packet includes a plurality of second heartbeat requests respectively corresponding to each of the first candidate links;
[0015] Receive at least one second response message, use the first candidate link corresponding to the second response message as the second candidate link, select a second target link from the second candidate links, and switch to the second target link for connection.
[0016] Optionally, after the step of generating and sending the second heartbeat collection packet, it further includes:
[0017] If the second response message fails to be received, generate and send the first heartbeat collection packet;
[0018] If at least one of the first response messages can be received, execute the step of using the communication link corresponding to each first response message as the first candidate link, and subsequent steps.
[0019] Optionally, after the step of generating and sending the first heartbeat collection packet, it further includes:
[0020] If the first response message fails to be received, after a preset time interval, re-execute the step of generating and sending the first heartbeat collection packet, and subsequent steps.
[0021] Optionally, the step of selecting a second target link from the second candidate links includes:
[0022] Obtain the response time of each second candidate link according to the reception time of each second response message;
[0023] Perform priority sorting on the second candidate links based on the priority rule and the response time, and use the second candidate link ranked first as the second target link.
[0024] Optionally, the connection method includes at least one of: ipv4 network direct connection, ipv6 network direct connection, DDNS connection, P2P direct connection, server domain name forwarding connection;
[0025] The priority rules include: direct connection of ipv4 network = direct connection of ipv6 network > DDNS connection > P2P direct connection > server domain name forwarding connection.
[0026] The present invention also discloses a connection management system for devices, where the client device and the server device can establish a connection through communication links of multiple different connection methods;
[0027] The connection management system for devices includes:
[0028] An acquisition module, configured to acquire connection information of the server device, and establish a connection with the server device based on the connection information, where the connection information includes the communication link;
[0029] A sending module, configured to generate a first heartbeat set packet including a plurality of first heartbeat requests, and each of the communication links corresponds to at least one of the first heartbeat requests;
[0030] A receiving module, configured to send the first heartbeat set packet, and receive at least one first response message, use the communication link corresponding to each first response message as a first candidate link, and obtain the response time of each first candidate link according to the reception time of each first response message;
[0031] A sorting module, configured to perform priority sorting on the first candidate links based on a preset priority rule and the response time, and use the first candidate link ranked first as the first target link;
[0032] A switching module, configured to determine whether the priority of the currently used communication link is higher than that of the first target link, and if so, switch to the first target link for connection.
[0033] The present invention also discloses a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the processor is caused to execute the steps as described above.
[0034] The present invention also discloses an electronic device including a memory and a processor, where the memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to execute the steps as described above.
[0035] The present invention also discloses a device connection management system including: a network attached storage device and the electronic device as described above, and an application program capable of executing the steps of the method as described above is installed in the electronic device.
[0036] Compared with the prior art, the beneficial effects of the device connection management method provided by the embodiments of the present invention are as follows:
[0037] While establishing a connection between the client device and the hardware device, all communication links between the client device and the hardware device are detected, and the one with the best communication quality is selected as the first target link. If the priority of the communication link used for the current connection establishment is lower than that of the first target link, the connection is switched to the first target link. This can ensure that the client device and the hardware device can establish a connection quickly, and at the same time, it can also switch to the communication link with the best communication quality as soon as possible. By generating and sending a first heartbeat set packet including multiple first heartbeat requests, the time taken to obtain the communication quality of each communication link can be greatly reduced, and the first target link can be obtained more quickly, so that the client device and the server device can use the communication link with the best communication quality to establish a connection more quickly. Brief Description of the Drawings
[0038] The solution of the present invention will be further described in detail below in conjunction with the drawings and embodiments. In the drawings:
[0039] Figure 1 is a schematic flowchart of the first embodiment of the device connection management method provided by the present invention;
[0040] Figure 2 is a schematic diagram of the application scenario of the device connection management method provided by the present invention;
[0041] Figure 3 is a schematic flowchart of the second embodiment of the device connection management method provided by the present invention;
[0042] Figure 4 is a schematic flowchart of the third embodiment of the device connection management method provided by the present invention;
[0043] Figure 5 is a schematic structural diagram of an embodiment of the device connection management system provided by the present invention;
[0044] Figure 6 shows a schematic internal structure diagram of an electronic device in an embodiment;
[0045] Figure 7 is a schematic structural diagram of an embodiment of the device connection management system provided by the present invention.
[0046] The reference numerals in the drawings are as follows:
[0047] 1. Device connection management system; 11. Acquisition module; 12. Sending module; 13. Receiving module; 14. Sorting module; 15. Switching module;
[0048] 20. Device connection management system; 21. Electronic device; 22. Network attached storage device. Detailed Description of the Embodiments
[0049] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. Now, in conjunction with the accompanying drawings, detailed descriptions of the preferred embodiments of the present invention will be given.
[0050] Please refer to Figure 1 and Figure 2 , Figure 1 which is a schematic flowchart of the first embodiment of the device connection management method provided by the present invention. Figure 2 which is a schematic diagram of the application scenario of the device connection management method provided by the present invention. As Figure 2 shown, the client device 1 and the server device 2 can be connected through multiple communication links using different connection methods. For example, the client device 1 and the server device 2 can be connected through three connection methods A, B, and C. The number of communication links 3 is 3, and each communication link is connected using one connection method. Specifically, communication link a uses connection method A, communication link b uses connection method B, and communication link c uses connection method C. When there are multiple communication links 3 in an available state, it is necessary to select the optimal one for connection to ensure the communication quality between the client device 1 and the server device 2 and maintain a stable communication effect.
[0051] The client device 1 and the server device 2 can be a UGC (User-Generated Content) and a manager, or a mobile phone and a smart door lock, a mobile phone and a network camera, a mobile phone and a NAS (Network Attached Storage) device, or a NAS device and a NAS device.
[0052] The device connection management method provided by the present invention includes the following steps:
[0053] S101: Obtain the connection information of the server device, and establish a connection with the server device based on the connection information.
[0054] In a specific implementation scenario, the client device initializes the connection state, including setting initial connection parameters, establishing an initial connection environment, etc. Then, according to the identifier or other information of the server device, the connection information of the server device is searched. The connection information includes the connection address or URI. Once the connection URI of the server device is successfully found, the search result will be obtained. This search result usually includes the specific connection address, connection method, port information, etc. of the server device. After obtaining this information, the client device can use this data to establish a communication connection with the server device.
[0055] The connection information also includes the communication link between the client device and the server device. By identifying the network environment supported by the client device (such as cellular network or Wi-Fi network), the connection methods supported by the device can be determined. For example, if the client device is currently connected to a cellular network, it may mean that it supports connection via the mobile network (connection method A); if the client device is connected to a Wi-Fi network, it may indicate that it supports connection via Wi-Fi (connection method B). By monitoring the network type to which the device is connected, the connection methods supported by the device can be determined, and the communication link that can be established between the client device and the server device can be obtained.
[0056] Before connection, a system service check is required. Specifically, before establishing a connection, the interface of "whether the service is started" in the service of the server device will be called first to check the status of the server device. The role of the interface of "whether the service is started" is to detect whether the service on the server device has been in the started state. Since the server device may have just been powered on or restarted, special attention needs to be paid to the status of the hardware at this time. Although it may be possible to find available connections for the server device, if the service of the server device is started in steps, the login service may not have been fully started. This means that although the connection may have been established, the service of the server device is not fully ready and cannot continue to establish a device connection. If an attempt is made to establish a device connection in this situation, it may result in connection establishment failure, communication anomalies, or other adverse effects. Therefore, before attempting to establish a device connection, the interface of "whether the service is started" is called to confirm the full start of the peer service. Only when the server device is fully ready should the connection process continue to ensure the smooth establishment and normal operation of the connection.
[0057] After the system service check determines that the server device is fully ready, the client device sends a login request to the server device, requesting to establish a connection. After receiving the login request, the server device performs authentication verification, confirms the identity and permissions of the client device, and returns a login success or login failure response to the client device according to the authentication result. After receiving the login response, the client device checks the status information in the response to determine whether the login is successful.
[0058] After successful login, a TLS (Transport Layer Security) handshake will be performed between the client device and the server device to negotiate encryption parameters. After successfully completing the TLS handshake, an encrypted channel is established between the two parties to ensure the confidentiality and integrity of communication data. After establishing a secure TLS connection, the client device and the server device can start data transmission. The client device issues a connection method change notice based on the currently adopted communication link to update the connection information (such as IP address, port, etc.).
[0059] S102: Generate a first heartbeat set packet including multiple first heartbeat requests, where each communication link corresponds to at least one first heartbeat request.
[0060] In a specific implementation scenario, the client device first arbitrarily selects a connection from multiple communication links according to the connection information, so as to establish a connection between the client device and the server device as soon as possible. While establishing the connection, all communication links can be detected to select the best-quality communication link therefrom.
[0061] Specifically, a corresponding first heartbeat request can be generated for each communication link. For different communication links, based on the characteristics of the communication link and the corresponding connection method, the specific implementation of the first heartbeat request may be different. For example, the first heartbeat request corresponding to IPv4 and IPv6 network direct connection can be a simple ping request, which is used to detect the device's survival status and whether the network connection is normal.
[0062] Combine all the first heartbeat requests into a first heartbeat set packet.
[0063] S103: Send the first heartbeat set packet and receive at least one first response message. Use the communication link corresponding to each first response message as a first candidate link, and obtain the response time of each first candidate link according to the reception time of each first response message.
[0064] In a specific implementation scenario, send the first heartbeat set packet so that all the first heartbeat requests can be sent simultaneously, thereby detecting the communication quality of multiple communication links in parallel. If a communication link can communicate normally, the client device will receive the first response message feedback by the server device through this communication link. If a communication link cannot communicate normally, the client device will not receive the first response message corresponding to this communication link.
[0065] Therefore, the client device can obtain the communication links that can work normally among all communication links based on the result of whether the first response message is received. Use the communication link corresponding to the received first response message as a first candidate link, and select the first target link for connection from the first candidate links, which can ensure that the selected first target link has normal communication functions.
[0066] Since all the first heartbeat requests are sent simultaneously when the first heartbeat set packet is sent, the response time of each communication link can be obtained according to the order of receiving the first response messages. For example, taking the time when the first heartbeat set packet is sent as the 0 moment, if the first response message returned by communication link A is received at time t1, then the response time of communication link A is t1, and so on to obtain the response times of other communication links.
[0067] S104: Prioritize the first candidate links based on a preset priority rule and response time, and use the first candidate link ranked first as the first target link.
[0068] In a specific implementation scenario, there is a preset priority rule, which is sorted based on different communication methods. For example Figure 2 In the scenario shown, the preset priority rule is Communication Method A = Communication Method B > Communication Method C. According to the priority sorting of the communication methods, the corresponding communication links are prioritized, and the priority of the corresponding communication links is Communication Link a = Communication Link b > Communication Link c.
[0069] In one embodiment, the connection methods include at least one of direct ipv4 network connection, direct ipv6 network connection, DDNS connection, P2P direct connection, and server domain name forwarding connection. The corresponding priority rules include: direct ipv4 network connection = direct ipv6 network connection > DDNS connection > P2P direct connection > server domain name forwarding connection.
[0070] Prioritize the first candidate links based on a preset priority rule and response time. It can be based on the order of the priority rule. If the priority levels of two first candidate links are the same, then sort based on the length of the response time. The shorter the response time, the higher the ranking. For example, Figure 2 In the scenario shown, the response time of Communication Link a is shorter than that of Communication Link b. Then the corresponding priority sorting result is Communication Link a > Communication Link b > Communication Link c. Use the first candidate link ranked first as the first target link. Figure 2 In the scenario in, Communication Link a is the first target link.
[0071] S105: Determine whether the priority of the currently used communication link is lower than that of the first target link. If not, execute step S106.
[0072] S106: Switch to the first target link for connection.
[0073] In a specific implementation scenario, obtain the priority of the currently used communication link. If the priority is lower than that of the first target link, then it means that the communication quality of the first target link is better, and switch to the first target link for connection, which can effectively ensure that high-quality communication can be maintained between the client device and the server device. For example, in Figure 2 In the scenario shown, if the currently used communication link is Communication Link c, then switch to use Communication Link a for connection.
[0074] In other implementation scenarios, it is possible that the currently adopted communication link is the first target link, or the priority of the currently sampled communication link is equal to that of the first target link. In this case, no switching is performed, and the current high-quality communication is maintained to avoid resource waste.
[0075] Since the client device has logged in successfully during this handover, there is no need to perform the login operation again. However, due to the change of the communication link, the client device and the server device will perform a TLS handshake again to establish an encrypted channel and start data transmission. The client device sends a first connection method change notification based on the currently adopted communication link (the first target link) to update the connection information (such as IP address, port, etc.).
[0076] From the above description, it can be seen that in this embodiment, while the client device establishes a connection with the hardware device, all communication links between the client device and the hardware device are detected, and the one with the best communication quality is selected as the first target link. If the priority of the communication link currently used for establishing the connection is lower than that of the first target link, the connection is switched to the first target link, which can ensure that the client device and the hardware device can establish a connection quickly, and at the same time, can also be switched to the communication link with the best communication quality as soon as possible for connection, generate and send a first heartbeat set packet including multiple first heartbeat requests, which can greatly reduce the time for obtaining the communication quality of each communication link and obtain the first target link more quickly, so that the client device and the server device can use the communication link with the best communication quality for connection more quickly.
[0077] Please refer to Figure 2 and Figure 3 , Figure 3 which is a schematic flowchart of the second embodiment of the device connection management method provided by the present invention. The device connection management method provided by the present invention further includes the following steps:
[0078] S201: Obtain the current communication quality information, and determine whether to switch the communication link based on the current communication quality information. If so, execute step S202.
[0079] In a specific implementation scenario, after the client device and the server device establish a connection, the client device periodically or as needed collects communication quality information, including but not limited to latency, packet loss rate, bandwidth utilization rate, etc., and evaluates the current communication quality through the collected data to determine the stability and performance level of the current connection. Some thresholds can be set. For example, a maximum latency time and a maximum packet loss rate can be set, and the current communication quality information is compared with these thresholds. If at least one of them is lower than the threshold, it is determined that the communication link needs to be switched to maintain the high communication quality between the client device and the server device.
[0080] S202: Generate and send a second heartbeat collection packet, where the second heartbeat collection packet includes multiple second heartbeat requests respectively corresponding to each first candidate link.
[0081] In a specific implementation scenario, generate a corresponding second heartbeat request based on each first candidate link selected above, use the collection of all second heartbeat requests as the second heartbeat collection packet, and send the second heartbeat collection packet so that all second heartbeat requests can be sent simultaneously, thereby enabling parallel inspection of the communication quality of each first candidate link.
[0082] The first candidate links are the links with normal communication functions selected from all communication links during the last successful connection. Selecting the second target link for switching from the first candidate links can increase the probability of successfully selecting the second target link, reduce the workload of searching and screening, increase the probability of successful switching, and ensure the continuity of high-quality communication between the client device and the server device.
[0083] S203: Receive at least one second response message, use the first candidate link corresponding to the second response message as the second candidate link, select the second target link from the second candidate links, and switch to the second target link for connection.
[0084] In a specific implementation scenario, due to changes in the network environment, the communication quality of some first candidate links may deteriorate. Therefore, send a second heartbeat collection packet to check the communication quality of the first candidate links, receive at least one second response message, and use the first candidate link corresponding to the second response message as the second candidate link. The second candidate link is the communication link with normal communication functions among the first candidate links at the current moment.
[0085] Similar to selecting the first target link from all first candidate links, select the second target link from all second candidate links. Specifically, perform a priority ranking on the second candidate links based on the preset priority rules and the response time of receiving the second response message. It can be based on the order of the priority rules. If the priority levels of two second candidate links are the same, then rank them based on the length of the response time. The shorter the response time, the higher the ranking. Use the second candidate link ranked first as the second target link. Since the current communication quality is not good, there is no need to compare the priority levels of the currently used communication link and the second target link, and directly perform the switching operation to switch to the second target link for connection.
[0086] In other implementation scenarios, a second target link can be directly selected from the second candidate links, or the second target link can be selected from the second candidate links according to other selection rules.
[0087] However, due to the communication link switching operation, the client device and the server device will perform a TLS handshake again, establish an encrypted channel and start data transmission. The client device issues a second connection method change notification based on the currently adopted communication link (the second target link) to update connection information (such as IP address, port, etc.).
[0088] From the above description, it can be seen that in this embodiment, when it is detected that the communication quality of the currently adopted communication link is not high, a second target link with better communication quality can be automatically selected for switching to maintain high-quality communication between the client device and the server device, generate and send a second heartbeat set packet including multiple second heartbeat requests, which can greatly reduce the time for obtaining the communication quality of each communication link and obtain the second target link more quickly.
[0089] Please refer to Figure 2 and Figure 4 , Figure 4 which is a schematic flowchart of the third embodiment of the device connection management method provided by the present invention. The device connection management method provided by the present invention further includes the following steps:
[0090] S301: Obtain the current communication quality information, and judge whether it is necessary to switch the communication link based on the current communication quality information. If so, execute step S302.
[0091] S302: Generate and send a second heartbeat set packet, and the second heartbeat set packet includes multiple second heartbeat requests respectively corresponding to each first candidate link.
[0092] In a specific implementation scenario, steps S301 - S302 are basically the same as steps S201 - S202 in the second embodiment of the device connection management method provided by the present invention, and will not be elaborated here.
[0093] S303: If the second response information is not received, execute step S304.
[0094] In a specific implementation scenario, if the second response information is not received, it proves that all the first candidate links cannot communicate normally.
[0095] S304: Generate and send a first heartbeat set packet; judge whether at least one first response information is received. If so, execute step S305, if not, execute step S308.
[0096] In a specific implementation scenario, in order to enable the client device and the server device to resume high-quality communication as soon as possible, the communication quality of all communication links is detected to find out the available communication links as soon as possible. Generate and send a first heartbeat set packet, and judge whether at least one first response information is received.
[0097] S305: Take the communication link corresponding to each first response message as the first candidate link, and obtain the response time of each first candidate link according to the reception time of each first response message.
[0098] S306: Obtain the preset priority rule, perform priority sorting on the first candidate links based on the priority rule and the response time, and take the first candidate link ranked first as the first target link.
[0099] In a specific implementation scenario, steps S304 - S306 are basically the same as steps S103 - S104 in the first embodiment of the device connection management method provided by the present invention, and will not be elaborated here.
[0100] S307: Switch to the first target link for connection.
[0101] In a specific implementation scenario, if the first target link with the optimal communication quality can be selected from all communication links, then switch to the first target link for connection to ensure high-quality communication between the client device and the server device.
[0102] S308: After an interval of a preset duration, re-execute step S304 and subsequent steps.
[0103] In a specific implementation scenario, if the first response message is not received, it proves that the current communication quality is poor and there is no communication link that can communicate normally. After an interval of a preset duration, re-execute generating and sending the first heartbeat set packet to detect whether there is a communication link that can work properly, and perform a timely switch to cope with the poor communication quality situation and ensure the normal operation of the communication connection.
[0104] As can be seen from the above description, in this embodiment, if the second response message is not received, it proves that there is no available communication link among the first candidate links. Then, expand the detection range to detect all communication links, increase the probability of finding available communication links, reduce the communication interruption time, and maintain the communication between devices.
[0105] Please refer to Figure 5 , Figure 5 is a schematic structural diagram of an embodiment of the connection management system of the device provided by the present invention. The connection management system 10 of the device is applied to Figure 2 the client device in.
[0106] The connection management system 10 of the device includes: an acquisition module 11, a sending module 12, a receiving module 13, a sorting module 14, and a switching module 15.
[0107] The obtaining module 11 is used to obtain the connection information of the server device, establish a connection with the server device based on the connection information, and the connection information includes the communication link; the sending module 12 is used to generate a first heartbeat set packet including a plurality of first heartbeat requests, and at least one first heartbeat request corresponds to each communication link; the receiving module 13 is used to send the first heartbeat set packet and receive at least one first response message, use the communication link corresponding to each first response message as the first candidate link, and obtain the response time of each first candidate link according to the receiving time of each first response message; the sorting module 14 is used to perform priority sorting on the first candidate links based on a preset priority rule and the response time, and use the first candidate link ranked first as the first target link; the switching module 15 is used to determine whether the priority of the currently used communication link is higher than that of the first target link, and if so, switch to the first target link for connection.
[0108] The switching module 15 is further used to obtain the current communication quality information, and determine whether it is necessary to switch the communication link based on the current communication quality information; if so, generate and send a second heartbeat set packet, and the second heartbeat set packet includes a plurality of second heartbeat requests respectively corresponding to each first candidate link; receive at least one second response message, use the first candidate link corresponding to the second response message as the second candidate link, select a second target link from the second candidate links, and switch to the second target link for connection.
[0109] The switching module 15 is further used to, if the second response message fails to be received, generate and send a first heartbeat set packet; if at least one first response message can be received, execute the step of using the communication link corresponding to each first response message as the first candidate link, and subsequent steps.
[0110] The switching module 15 is further used to, if the first response message fails to be received, after a preset time interval, re-execute the steps of generating and sending the first heartbeat set packet, and subsequent steps.
[0111] The switching module 15 is further used to obtain the reply time of each second candidate link according to the receiving time of each second response message; perform priority sorting on the second candidate links based on the priority rule and the reply time, and use the second candidate link ranked first as the second target link.
[0112] The connection methods include at least one of ipv4 network direct connection, ipv6 network direct connection, DDNS connection, P2P direct connection, and server domain name forwarding connection; the priority rule includes: ipv4 network direct connection = ipv6 network direct connection > DDNS connection > P2P direct connection > server domain name forwarding connection.
[0113] Figure 6The figure shows a schematic internal structure diagram of an electronic device in an embodiment. The electronic device may specifically be a terminal or a server. As Figure 6 shown, the electronic device includes a processor, a memory, and a network interface connected via a system bus. Among them, the memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the electronic device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor can implement the age recognition method. The internal memory may also store a computer program. When the computer program is executed by the processor, the processor can execute the age recognition method. Those skilled in the art can understand that Figure 6 the structure shown in the figure is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the electronic device to which the solution of this application is applied. The specific electronic device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0114] In one embodiment, an electronic device is provided, including a memory and a processor. The memory stores a computer program. When the computer program is executed by the processor, the processor executes the above steps.
[0115] In one embodiment, a computer-readable storage medium is provided, storing a computer program. When the computer program is executed by the processor, the processor executes the above steps.
[0116] Please refer to Figure 7 , Figure 7 which is a schematic structural diagram of an embodiment of the device connection management system provided by the present invention.
[0117] The device connection management system 20 includes the above-mentioned electronic device 21 and a network-attached storage device 22. An application program capable of executing the steps of the method described above is installed in the electronic device 21.
[0118] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, storage, database, or other medium used in the various embodiments provided in the present application can include non-volatile and / or volatile memories. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and Rambus dynamic RAM (RDRAM), etc.
[0119] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
[0120] It should be understood that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Those skilled in the art can modify the technical solutions described in the above embodiments or perform equivalent replacements for some of the technical features; and all such modifications and replacements should fall within the protection scope of the appended claims of the present invention.
Claims
1. A device connection management method, characterized in that, Applied to a client device, the client device and the server device can establish a connection through multiple communication links with different connection methods; The device connection management method includes: Obtaining the connection information of the server device, and establishing a connection with the server device based on the connection information, where the connection information includes the communication link; Generating a first heartbeat set packet including multiple first heartbeat requests, and at least one of the first heartbeat requests corresponds to each communication link; Sending the first heartbeat set packet, and receiving at least one first response message, taking the communication link corresponding to each first response message as a first candidate link, and obtaining the response time of each first candidate link according to the reception time of each first response message; Performing priority sorting on the first candidate links based on a preset priority rule and the response time, and taking the first candidate link ranked first as the first target link; Judging whether the priority of the currently adopted communication link is lower than that of the first target link. If not, switch to the first target link for connection.
2. The device connection management method according to claim 1, wherein The device connection management method further includes: Obtaining the current communication quality information, and judging whether it is necessary to switch the communication link based on the current communication quality information; If so, generating and sending a second heartbeat set packet, where the second heartbeat set packet includes multiple second heartbeat requests respectively corresponding to each first candidate link; Receiving at least one second response message, taking the first candidate link corresponding to the second response message as a second candidate link, selecting a second target link from the second candidate links, and switching to the second target link for connection.
3. The device connection management method according to claim 2, wherein After the step of generating and sending the second heartbeat set packet, it further includes: If the second response message fails to be received, generating and sending the first heartbeat set packet; If at least one first response message can be received, performing the step of taking the communication link corresponding to each first response message as a first candidate link, and subsequent steps.
4. The device connection management method according to claim 3, wherein After the step of generating and sending the first heartbeat set packet, it further includes: If the first response message fails to be received, after a preset time interval, re-performing the step of generating and sending the first heartbeat set packet, and subsequent steps.
5. The device connection management method according to claim 2, wherein The step of selecting a second target link from the second candidate links includes: Obtaining the reply time of each second candidate link according to the reception time of each second response message; Performing priority sorting on the second candidate links based on the priority rule and the reply time, and taking the second candidate link ranked first as the second target link.
6. The device connection management method according to any one of claims 1-5, characterized in that The connection methods include at least one of direct ipv4 network connection, direct ipv6 network connection, DDNS connection, P2P direct connection, and server domain name forwarding connection; The priority rule includes: direct ipv4 network connection = direct ipv6 network connection > DDNS connection > P2P direct connection > server domain name forwarding connection.
7. A connection management system for a device, characterized in that, The client device and the server device can establish a connection through multiple communication links with different connection methods; The connection management system of the device includes: An acquisition module, configured to acquire connection information of the server device, establish a connection with the server device based on the connection information, where the connection information includes the communication link; A sending module, configured to generate a first heartbeat set packet including a plurality of first heartbeat requests, and each of the communication links corresponds to at least one of the first heartbeat requests; A receiving module, configured to send the first heartbeat set packet, receive at least one first response message, use the communication link corresponding to each first response message as a first candidate link, and obtain the response time of each first candidate link according to the reception time of each first response message; A sorting module, configured to perform priority sorting on the first candidate links based on a preset priority rule and the response time, and use the first candidate link ranked first as the first target link; A switching module, configured to determine whether the priority of the currently used communication link is higher than that of the first target link, and if so, switch to the first target link for connection.
8. A computer-readable storage medium storing a computer program, which when executed by a processor causes the processor to execute the steps of the method according to any one of claims 1 to 6.
9. An electronic device including a memory and a processor, where the memory stores a computer program, and when the computer program is executed by the processor, it causes the processor to execute the steps of the method according to any one of claims 1 to 6.
10. A device connection management system, characterized in that Comprising: A network attached storage device and the electronic device according to claim 9, where an application program capable of executing the steps of the method according to any one of claims 1 to 6 is installed in the electronic device.
Citation Information
Cited By
Network link switching method and device, storage medium and electronic equipment
CN120512399A