Vpn tunnel backup guarantee method and device based on ping detection mechanism, equipment and medium
By employing a VPN tunnel backup and protection method based on a ping detection mechanism, and utilizing TCP communication and ping detection between primary and backup routers, a fast tunnel switching mechanism is achieved when the network is unstable. This solves the problem of data loss caused by VPN tunnel disconnection and provides a more stable data transmission environment.
Patent Information
- Application Number
- CN202411389811.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-08
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-10-08
AI Technical Summary
In existing technologies, VPN tunnels are prone to disconnection due to network instability after successful establishment, resulting in unstable data transmission, excessive latency, and data loss. In particular, there is a lack of effective backup and protection mechanisms when the network environment fluctuates.
A VPN tunnel backup and protection method based on ping detection mechanism is adopted. By using TCP communication between the primary and backup routes, the tunnel status is determined by ping detection results. The VPN tunnel with backup route enabled is detected or switched on periodically to ensure the stability and integrity of data transmission.
It provides a fast-response backup solution that can switch to a backup route in a timely manner when the tunnel is disconnected or the latency is too high, ensuring the stability and reliability of data transmission, adapting to complex network environments, and avoiding data loss.
Smart Images

Figure CN119276776A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of VPN tunnel transmission, and in particular to a VPN tunnel backup guarantee method, device, equipment and medium based on a ping detection mechanism. Background Art
[0002] In existing gateway devices, after the VPN tunnel is successfully established, if there is a large data delay and low transmission efficiency, it will cause some troubles in actual applications and easily cause data loss or instability. In addition, in the case of an unstable network environment, the VPN tunnel is prone to frequent disconnection and long disconnection, which is easy to cause data loss. This is because in the actual network environment, it is normal to have network fluctuations and instability, so it is necessary to avoid problems caused by such situations. Therefore, when this problem occurs, the backup VPN tunnel will be enabled, and the data can reach the set destination IP, so it can provide a stable network environment for VPN data transmission.
[0003] Simply put, in actual industrial applications, after the VPN tunnel is established, the original protection mechanism takes too long to restart after the tunnel is disconnected, which can easily cause data instability and loss, or because the tunnel is unstable and the delay is too large, resulting in data loss. Therefore, it is necessary to provide a VPN tunnel backup protection mechanism that can better switch the tunnel more quickly after the tunnel is disconnected or exceeds the set delay threshold, so as to ensure the stability of the VPN tunnel and the integrity of the transmitted data.
[0004] In view of this, this application is filed. Summary of the invention
[0005] The present invention provides a VPN tunnel backup guarantee method, device, equipment and medium based on a ping detection mechanism, which can at least partially improve the above-mentioned problem.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] A VPN tunnel backup guarantee method based on a ping detection mechanism, comprising:
[0008] Obtaining preset configuration information, configuring a primary route and a backup route according to the preset configuration information, and enabling a VPN tunnel mechanism function of the primary route to establish a PPP tunnel of the primary route, wherein the primary route and the backup route belong to the same local area network;
[0009] When it is determined that the PPP tunnel of the primary route is successfully established, the primary route is controlled to establish TCP communication with the backup route, and the backup route is informed of the PPP tunnel status of the primary route, wherein the PPP tunnel status of the primary route includes an address ping detection result;
[0010] Determine whether the address ping detection result reaches the threshold, generate a judgment result, and perform a timing detection or switch on the VPN tunnel mechanism function of the backup route according to the judgment result to establish a PPP tunnel of the backup route.
[0011] The present invention also provides a VPN tunnel backup protection device based on a ping detection mechanism, which includes:
[0012] A main route tunnel establishing unit, used to obtain preset configuration information, configure the main route and the backup route according to the preset configuration information, and enable the VPN tunnel mechanism function of the main route to establish a PPP tunnel of the main route, wherein the main route and the backup route belong to the same local area network;
[0013] A TCP communication unit, configured to control the main route to establish TCP communication with the backup route when it is determined that the PPTP tunnel of the main route is successfully established, and inform the backup route of the PPTP tunnel status of the main route, wherein the PPTP tunnel status of the main route includes an address ping detection result;
[0014] The routing switching unit is used to determine whether the address ping detection result reaches a threshold, generate a judgment result, and perform a timing detection or switch to open the VPN tunnel mechanism function of the backup route according to the judgment result to establish a PPP tunnel of the backup route.
[0015] The present invention also provides a VPN tunnel backup protection device based on a ping detection mechanism, comprising a memory and a processor, wherein a computer program is stored in the memory, and the computer program can be executed by the processor to implement a VPN tunnel backup protection method based on a ping detection mechanism as described in any one of the above.
[0016] The present invention also provides a computer-readable storage medium storing a computer program, wherein the computer program can be executed by a processor of a device where the computer-readable storage medium is located, so as to implement a VPN tunnel backup guarantee method based on a ping detection mechanism as described in any one of the above.
[0017] In summary, the VPN tunnel backup guarantee method based on the ping detection mechanism provides a method for faster response detection and a backup solution. Based on the TCP / IP protocol and the ping command, the VPN tunnel is monitored by analyzing the direct results of the ping and using the TCP / IP protocol. If a disconnection occurs, a judgment can be made in time, and corresponding processing can be performed according to the configuration and the set parameters. According to the result, it is determined whether to enable the VPN tunnel of the backup route. This method can provide a more stable and reliable VPN tunnel transmission environment in the VPN application process of the gateway device. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 It is a flow chart of a VPN tunnel backup guarantee method based on a ping detection mechanism provided by the first aspect of the present invention;
[0019] Figure 2 It is a flow chart of a VPN tunnel backup guarantee method based on a ping detection mechanism provided by the second aspect of the present invention;
[0020] Figure 3 It is a network topology diagram of a VPN tunnel backup guarantee method based on a ping detection mechanism provided by an embodiment of the present invention;
[0021] Figure 4 It is a first configuration diagram of a VPN tunnel backup guarantee method based on a ping detection mechanism provided by an embodiment of the present invention;
[0022] Figure 5 It is a second configuration diagram of the VPN tunnel backup guarantee method based on the ping detection mechanism provided by an embodiment of the present invention;
[0023] Figure 6 It is a module diagram of a VPN tunnel backup protection device based on a ping detection mechanism provided by the second embodiment of the present invention. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0025] refer to Figure 1 , Figure 2 As shown, the first embodiment of the present invention discloses a VPN tunnel backup protection method based on a ping detection mechanism, which can be executed by a VPN tunnel backup protection device based on a ping detection mechanism (hereinafter referred to as a protection device), and in particular, is executed by one or more processors in the protection device to implement the following method:
[0026] In actual applications, when using VPN tunnels, existing embedded devices are prone to disconnection after successful tunnel establishment, resulting in long-term tunnel abnormalities or large delays, thereby causing data communication loss. Therefore, a VPN tunnel backup guarantee method based on a ping detection mechanism is proposed, which is a more convenient and fast guarantee mechanism that can provide VPN tunnel services more stably in actual production applications.
[0027] S1, obtaining preset configuration information, configuring a primary route and a backup route according to the preset configuration information, and enabling a VPN tunnel mechanism function of the primary route to establish a PPP tunnel of the primary route, wherein the primary route and the backup route belong to the same local area network;
[0028] Specifically, step S1 includes: obtaining preset configuration information, and configuring a primary route and a backup route according to the preset configuration information;
[0029] Enable the PPP backup mechanism of the main route and establish the PPP tunnel of the main route.
[0030] S2, when it is determined that the PPP tunnel of the primary route is successfully established, control the primary route to establish TCP communication with the backup route, and inform the backup route of the PPP tunnel status of the primary route, wherein the PPP tunnel status of the primary route includes the address ping detection result;
[0031] In this embodiment, the application system device used in this method is an industrial routing device, but this method is not limited to industrial routing devices. The actual application of the VPN tunnel backup guarantee method based on the ping detection mechanism is roughly as follows Figure 3 As shown in the figure, there are four routers in the public network, of which R1 and R2 belong to the same LAN, and R3 and R4 belong to the same LAN. Figure 4 and Figure 5 As shown, according to the configuration, the PPTP backup mechanism is enabled, and one router is selected as the primary and the other as the backup. Because the primary and backup routers are directly in the same LAN, a TCP connection will be established to inform each other of the current status. The router enabled as the backup router will wait for the primary router TCP to send the corresponding PPTP status message before deciding whether to establish a PPTP tunnel. Figure 4 The IP in the tunnel is the IP with which the other end can communicate, and the backup IP is the IP address of the backup router in the local area network. Figure 5 The port in is the TCP port opened by the current router.
[0032] S3, determine whether the address ping detection result reaches the threshold, generate a judgment result, and perform a timing detection or switch to open the VPN tunnel mechanism function of the backup route according to the judgment result to establish a PPP tunnel of the backup route.
[0033] Specifically, step S3 includes: when the address ping detection result is that the number of ping detection failures does not reach the threshold or the average delay of the ping detection does not reach the threshold, performing a timing detection to continue to determine whether the address ping detection result reaches the threshold;
[0034] When the address ping detection result is that the number of ping detection failures reaches a threshold or the average delay of the ping detection reaches a threshold, the backup router is informed through TCP communication to turn on the VPN tunnel mechanism function, establish the PPP tunnel of the backup router, and at the same time turn off the VPN tunnel mechanism function of the main router.
[0035] See also Figure 3 In this embodiment, for example, when the PPP tunnel of the primary router is successfully established, but the ping detection of the address 192.168.8.88 fails three times, the current PPP tunnel establishment application will be closed, and the backup router will be informed through the TCP protocol that the PPP tunnel of the primary router has been closed. Then the backup router will establish the PPP tunnel according to the configured PPP tunnel information. Or, when the average delay of the ping detection of the address 192.168.8.88 exceeds the set threshold three times in a row, Figure 4 and Figure 5 If the network is unstable, the router will switch routes if the network is unstable. This solution is also applicable to VPN protocols such as l2tp, openvpn, ipsec, gre, gretap, etc.
[0036] Preferably, it also includes:
[0037] When it is determined that the PPP tunnel establishment of the main route fails, determine whether the PPP tunnel establishment time of the main route exceeds a preset time value;
[0038] If not, enable the VPN tunnel mechanism function of the main router and establish a PPP tunnel of the main router;
[0039] If so, inform the backup router through TCP communication to enable the VPN tunnel mechanism function, establish the PPP tunnel of the backup router, and at the same time disable the VPN tunnel mechanism function of the main router.
[0040] In this embodiment, the experimental process of the VPN tunnel backup guarantee method based on the ping detection mechanism is mainly as follows: the first step is to enable the VPN tunnel mechanism function of the primary and backup routes; the second step is to establish TCP communication with the backup route after the VPN tunnel of the primary route is established, and inform the tunnel status of the primary route; the third step is to switch to the backup route if the VPN tunnel of the primary route has not been established within ten minutes; the fourth step is that the backup route is also established according to the VPN tunnel information configured by itself; the fifth step is to trigger the set threshold during use and switch the tunnel.
[0041] In summary, the VPN tunnel backup guarantee method based on the ping detection mechanism provides a VPN tunnel backup guarantee mechanism solution based on the ping detection mechanism based on the ping tool and the TCP protocol. Through this mechanism, a more stable VPN tunnel switching mechanism can be provided to ensure the integrity of the communication data. Compared with the prior art, a more reliable guarantee mechanism is provided, which can better adapt to relatively complex network environments, avoid the instability of data transmission caused by network environment problems, and provide better guarantee for production applications.
[0042] See also Figure 6 The second embodiment of the present invention provides a VPN tunnel backup protection device based on a ping detection mechanism, which includes:
[0043] The main route tunnel establishing unit 201 is used to obtain preset configuration information, configure the main route and the backup route according to the preset configuration information, and enable the VPN tunnel mechanism function of the main route to establish a PPP tunnel of the main route, wherein the main route and the backup route belong to the same local area network;
[0044] The TCP communication unit 202 is used to control the main route to establish TCP communication with the backup route when it is determined that the PPP tunnel of the main route is successfully established, and inform the backup route of the PPP tunnel status of the main route, wherein the PPP tunnel status of the main route includes the address ping detection result;
[0045] The routing switching unit 203 is used to determine whether the address ping detection result reaches a threshold, generate a judgment result, and perform a timing detection or switch to open the VPN tunnel mechanism function of the backup route according to the judgment result to establish a PPP tunnel of the backup route.
[0046] Preferably, the main route and the backup route are configured according to the preset configuration information, and the VPN tunnel mechanism function of the main route is enabled, specifically:
[0047] Obtain preset configuration information, and configure the primary route and the backup route according to the preset configuration information;
[0048] Enable the PPP backup mechanism of the main route and establish the PPP tunnel of the main route.
[0049] Preferably, it is determined whether the address ping detection result reaches a threshold, a determination result is generated, and a timing detection is performed or the VPN tunnel mechanism function of the backup route is switched on according to the determination result to establish a PPP tunnel of the backup route, specifically:
[0050] When the address ping detection result is that the number of ping detection failures does not reach the threshold or the average delay of the ping detection does not reach the threshold, a timed detection is performed to continue to determine whether the address ping detection result reaches the threshold;
[0051] When the address ping detection result is that the number of ping detection failures reaches a threshold or the average delay of the ping detection reaches a threshold, the backup router is informed through TCP communication to turn on the VPN tunnel mechanism function, establish the PPP tunnel of the backup router, and at the same time turn off the VPN tunnel mechanism function of the main router.
[0052] Preferably, it also includes:
[0053] When it is determined that the PPP tunnel establishment of the main route fails, determine whether the PPP tunnel establishment time of the main route exceeds a preset time value;
[0054] If not, enable the VPN tunnel mechanism function of the main router and establish a PPP tunnel of the main router;
[0055] If so, inform the backup router through TCP communication to enable the VPN tunnel mechanism function, establish the PPP tunnel of the backup router, and at the same time disable the VPN tunnel mechanism function of the main router.
[0056] The third embodiment of the present invention provides a VPN tunnel backup protection device based on a ping detection mechanism, including a memory and a processor, wherein a computer program is stored in the memory, and the computer program can be executed by the processor to implement the VPN tunnel backup protection method based on the ping detection mechanism as described in any one of the above.
[0057] A fourth embodiment of the present invention provides a computer-readable storage medium storing a computer program, wherein the computer program can be executed by a processor of a device where the computer-readable storage medium is located, so as to implement a VPN tunnel backup guarantee method based on a ping detection mechanism as described in any one of the above.
[0058] Exemplarily, the above-mentioned devices and process steps can be implemented by a computer program. The computer program can be divided into one or more units. The one or more units are stored in the memory and executed by the processor to complete the present invention.
[0059] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0060] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the present invention by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0061] Wherein, if the electronic device or printer integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0062] It should be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the accompanying drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art may understand and implement it without paying any creative effort.
[0063] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A VPN tunnel backup protection method based on ping detection mechanism, characterized in that: include: Obtaining preset configuration information, configuring a primary route and a backup route according to the preset configuration information, and enabling a VPN tunnel mechanism function of the primary route to establish a PPP tunnel of the primary route, wherein the primary route and the backup route belong to the same local area network; When it is determined that the PPP tunnel of the primary route is successfully established, the primary route is controlled to establish TCP communication with the backup route, and the backup route is informed of the PPP tunnel status of the primary route, wherein the PPP tunnel status of the primary route includes an address ping detection result; Determine whether the address ping detection result reaches the threshold, generate a judgment result, and perform a timing detection or switch on the VPN tunnel mechanism function of the backup route according to the judgment result to establish a PPP tunnel of the backup route.
2. The VPN tunnel backup protection method based on the ping detection mechanism according to claim 1 is characterized in that: Configure the primary route and backup route according to the preset configuration information, and enable the VPN tunnel mechanism function of the primary route, specifically: Obtain preset configuration information, and configure the primary route and the backup route according to the preset configuration information; Enable the PPP backup mechanism of the main route and establish the PPP tunnel of the main route.
3. The VPN tunnel backup protection method based on ping detection mechanism according to claim 1 is characterized in that: Determine whether the address ping detection result reaches the threshold, generate a judgment result, and perform a timed detection or switch on the VPN tunnel mechanism function of the backup route according to the judgment result, and establish a PPP tunnel of the backup route, specifically: When the address ping detection result is that the number of ping detection failures does not reach the threshold or the average delay of the ping detection does not reach the threshold, a timed detection is performed to continue to determine whether the address ping detection result reaches the threshold; When the address ping detection result is that the number of ping detection failures reaches a threshold or the average delay of the ping detection reaches a threshold, the backup router is informed through TCP communication to turn on the VPN tunnel mechanism function, establish the PPP tunnel of the backup router, and at the same time turn off the VPN tunnel mechanism function of the main router.
4. The VPN tunnel backup protection method based on ping detection mechanism according to claim 1 is characterized in that: Also includes: When it is determined that the PPP tunnel establishment of the main route fails, determine whether the PPP tunnel establishment time of the main route exceeds a preset time value; If not, enable the VPN tunnel mechanism function of the main router and establish a PPP tunnel of the main router; If so, inform the backup router through TCP communication to enable the VPN tunnel mechanism function, establish the PPP tunnel of the backup router, and at the same time disable the VPN tunnel mechanism function of the main router.
5. A VPN tunnel backup protection device based on ping detection mechanism, characterized in that: include: A main route tunnel establishing unit, used to obtain preset configuration information, configure the main route and the backup route according to the preset configuration information, and enable the VPN tunnel mechanism function of the main route to establish a PPP tunnel of the main route, wherein the main route and the backup route belong to the same local area network; A TCP communication unit, configured to control the main route to establish TCP communication with the backup route when it is determined that the PPTP tunnel of the main route is successfully established, and inform the backup route of the PPTP tunnel status of the main route, wherein the PPTP tunnel status of the main route includes an address ping detection result; The routing switching unit is used to determine whether the address ping detection result reaches a threshold, generate a judgment result, and perform a timing detection or switch to open the VPN tunnel mechanism function of the backup route according to the judgment result to establish a PPP tunnel of the backup route.
6. The VPN tunnel backup protection device based on ping detection mechanism according to claim 5 is characterized in that: Configure the primary route and backup route according to the preset configuration information, and enable the VPN tunnel mechanism function of the primary route, specifically: Obtain preset configuration information, and configure the primary route and the backup route according to the preset configuration information; Enable the PPP backup mechanism of the main route and establish the PPP tunnel of the main route.
7. The VPN tunnel backup protection device based on ping detection mechanism according to claim 5 is characterized in that: Determine whether the address ping detection result reaches the threshold, generate a judgment result, and perform a timed detection or switch on the VPN tunnel mechanism function of the backup route according to the judgment result, and establish a PPP tunnel of the backup route, specifically: When the address ping detection result is that the number of ping detection failures does not reach the threshold or the average delay of the ping detection does not reach the threshold, a timed detection is performed to continue to determine whether the address ping detection result reaches the threshold; When the address ping detection result is that the number of ping detection failures reaches a threshold or the average delay of the ping detection reaches a threshold, the backup router is informed through TCP communication to turn on the VPN tunnel mechanism function, establish the PPP tunnel of the backup router, and at the same time turn off the VPN tunnel mechanism function of the main router.
8. The VPN tunnel backup protection device based on ping detection mechanism according to claim 5 is characterized in that: Also includes: When it is determined that the PPP tunnel establishment of the main route fails, determine whether the PPP tunnel establishment time of the main route exceeds a preset time value; If not, enable the VPN tunnel mechanism function of the main router and establish a PPP tunnel of the main router; If so, inform the backup router through TCP communication to enable the VPN tunnel mechanism function, establish the PPP tunnel of the backup router, and at the same time disable the VPN tunnel mechanism function of the main router.
9. A VPN tunnel backup protection device based on ping detection mechanism, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program, and the computer program can be executed by the processor to implement the VPN tunnel backup guarantee method based on the ping detection mechanism as described in any one of claims 1 to 4.
10. A computer-readable storage medium, characterized in that: A computer program is stored, and the computer program can be executed by a processor of the device where the computer-readable storage medium is located to implement the VPN tunnel backup guarantee method based on the ping detection mechanism as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Method and data for transmitting data between local area networks
CN102833167A
Route detection method and apparatus
CN107547376A
Method and system for creating VPN channel by multilink backup, and storage medium
CN110519148A
VPN transmission tunnel scheduling method and device, and VPN client-end server
WO2018094654A1