A multi-device GRE tunnel communication method

CN117834343BActive Publication Date: 2026-10-30XIAMEN ALOTCER COMM TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311773038.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-21
Publication Date
2026-10-30
Estimated Expiration
2043-12-21

AI Technical Summary

Technical Problem

一旦中心端设备故障,会导致整个gretap网络瘫痪

Benefits of technology

当中心端故障时,子设备可以及时感知并重新在GRE设备组中动态枚举新的中心端,保证网络持续稳定。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117834343B_ABST
    Figure CN117834343B_ABST
Patent Text Reader

Abstract

The present application relates to a kind of multi-device GRE tunnel communication method, comprising the following processes: a. at least part of the router device on network is made into GRE device group, and router device in GRE device group is interconnected two by two;B. in GRE device group, enumerate center end device, after enumeration success, the rest of the device is sub-device;C. the GRE tunnel between the center end device and each sub-device is established, the center end device receives the message of sub-device and replies to message, and the sub-device receives the message of center end device and replies to message, and mutual communication is realized;D. if the center end device is not replied in timeout, it is judged that the center end is abnormal, and existing GRE tunnel is destroyed;Repeat above process a to c, and reestablish GRE tunnel.When the center end fails, sub-device can be sensed in time and reestablishes new center end in GRE device group dynamically, and guarantee network continues stable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer network communication technology, and in particular to a multi-device GRE tunnel communication method. Background Technology

[0002] GRE (Generic Routing Encapsulation) is a lightweight tunneling protocol that encapsulates various network protocols (IP, IPSec, DVMRP, etc.) into IP tunnels, creating a virtual point-to-point tunnel link between routers on the other end via IP. This allows the encapsulated data packets to be transmitted within another network layer using the IP protocol. It enables IP interconnection between devices on different local area networks. GRE can be simply understood as an IP-over-IP tunneling technology. TAP devices can read and write link-layer data packets. Based on the technical principles of GRE and the advantages of TAP, when special packet encapsulation technology is used for GRETAP data communication via TAP, it is possible to read and write link-layer data packets, such as PPP / ARP / MTU / CSLIP, thereby achieving data transmission at the data link layer. This allows devices to completely break free from the structural limitations of Layer 2 and 3 networks, providing the technical conditions for data link interconnection between network communication devices distributed in different areas.

[0003] Existing Gretap tunnels are created using the following method: 1. Create a Gretap type virtual network interface and specify the local public IP address and the remote public IP address. 2. Configure the tunnel IP address for the Gretap virtual network interface. 3. Add the Gretap virtual network port and the LAN interface to the br bridge, because the bridge's packet forwarding rules are as follows: The bridge's forwarding rule is that when the bridge receives a frame from port x: ① Search the MAC table to determine if the MAC address is on a port; ② If the MAC address is not found, then flood the frame to all ports (except x); ③ If the MAC address corresponding to port y is found, then check port y. If port y is not in a blocked state, then send from port y. If port y is in a blocked state, then do not send.

[0004] like Figure 1As shown, referring to the packet forwarding rules of the network bridge, LAN IP packets can be forwarded to the Gretap virtual network interface through the network bridge, and then encapsulated by Gretap packets before being forwarded to the other end. After receiving the packets, the other end unpacks the IP packets and forwards them to the Gretap virtual network interface, and then forwards them to the local LAN through the network bridge. This enables the two devices to communicate in the LAN through the Gretap tunnel.

[0005] As can be seen from the above process of creating a Gretap tunnel, Gretap tunnels are one-to-one point-to-point communication. Each tunnel requires specifying the local and remote public IP addresses. If multi-device tunnel communication is needed, one device must be designated as the central endpoint. All communication packets must be forwarded through the central endpoint. If the central endpoint fails, the entire Gretap network will be paralyzed. Therefore, the existing Gretap multi-tunnel communication method relies on the stability of a fixed central endpoint, which is unreliable. Summary of the Invention

[0006] The purpose of this invention is to provide a technical means to solve the communication stability problem of existing technologies that rely on a fixed center end, while ensuring multi-device GRE tunnel communication.

[0007] To achieve the above objectives, this invention discloses a multi-device GRE tunnel communication method, comprising the following steps: a. Group at least some of the router devices on the network into GRE device groups, and interconnect the router devices in the GRE device groups with each other; b. Enumerate the central devices in the GRE device group. After successful enumeration, the remaining devices are sub-devices. c. A GRE tunnel is established between the central terminal device and each sub-device. The central terminal device receives messages from the sub-devices and replies to the messages, and the sub-devices receive messages from the central terminal device and reply to the messages, thereby enabling mutual communication. d. If the central device fails to respond within the timeout period, the central device is deemed abnormal, and the existing GRE tunnel is destroyed; repeat the above process a to c to re-establish the GRE tunnel; e. If the sub-device fails to respond within the timeout period, the sub-device is deemed abnormal, and the existing GRE tunnel is destroyed; repeat the above process a to c to re-establish the GRE tunnel.

[0008] The preferred method for enumerating central end devices in the GRE device group is as follows: b1. Each router in the GRE device group is assigned a unique ID number; each router sends a message with its own device ID number to the other devices; the comparison rules for the central device ID number are pre-configured; b2. Each router device receives a message from other devices, compares the ID number of the other devices with its own ID number, and if its own ID number matches the pre-set comparison rules, it updates the current device as the central device; After multiple rounds of b1 and b2 processes, a unique central terminal device is enumerated in the GRE device group.

[0009] Preferably, in b1, the ID number of the router device is dynamically generated, and the ID number of the router device is dynamically generated based on the current time as a random number.

[0010] Preferably, the comparison rule for the central device ID is: the ID number is the largest or smallest at present.

[0011] Preferably, the router devices in the GRE device group are interconnected with each other via TCP.

[0012] Preferably, after receiving messages from other devices, the router device needs to reply with an ACK message, compare the ID number of the other devices with its own ID number, and update whether it has become a central device. The central devices that have been successfully enumerated periodically send messages to the sub-devices, the message content of which includes the ID number and public network address of the central device. After receiving the message, the sub-device needs to reply with an ACK message to indicate that the current sub-device is working normally.

[0013] Preferably, the method for establishing GRE tunnels between the central terminal device and each sub-device includes: c1. Create a virtual network interface of type GRE, and specify the local public IP address and the remote public IP address; c2. Configure the tunnel IP for the GRE virtual network port; c3. Add the GRE virtual network port and the LAN interface to the br bridge to establish a GRE tunnel between the central device and the sub-device.

[0014] Preferably, the router devices in the GRE device group are connected to at least one terminal device. The router devices obtain public network addresses and terminal device addresses through GRE tunnel communication and establish a network neighbor table. The terminal devices, router devices, or terminal devices communicate with each other by querying the network neighbor table to obtain the address of the communication object and use the address to communicate.

[0015] Preferably, the terminal device and the router device are connected via a Layer 2 network connection.

[0016] Preferably, the network neighbor table includes the router device address and the terminal device address. After one or more terminal devices disconnect from the router device, the network neighbor table is re-established.

[0017] The present invention has the following beneficial effects: When the central terminal fails, the sub-devices can promptly detect the failure and dynamically enumerate a new central terminal in the GRE device group, ensuring continuous network stability. Attached Figure Description

[0018] Figure 1 This is a schematic diagram of the interface data topology of the Gretap tunnel provided in a specific embodiment of the present invention; Figure 2 This is a connection diagram of the GRE device group provided in a specific embodiment of the present invention; Figure 3 This is a schematic diagram of device connection provided in a specific embodiment of the present invention. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments.

[0020] like Figures 2-3 As shown, this invention discloses a multi-device GRE tunnel communication method, comprising the following processes: a. Group the router devices that are needed and working properly on the network into GRE device groups. The router devices in the GRE device group are interconnected in pairs via TCP. b. Enumerate the central devices in the GRE device group. After successful enumeration, the remaining devices are sub-devices. c. Establish GRE tunnels between the central device and each sub-device. After the GRE tunnels are established, the central device needs to send messages to the sub-devices periodically. The message content includes the device ID and public network address. After receiving the message from the central device, the sub-device needs to reply with an ack message to indicate that the sub-device is working normally. d. If the central device fails to respond within the timeout period, the central device is deemed abnormal, and the existing GRE tunnel is destroyed; repeat the above process a to c to re-establish the GRE tunnel; e. If the sub-device fails to respond within the timeout period, the sub-device is deemed abnormal, and the existing GRE tunnel is destroyed; repeat the above process a to c to re-establish the GRE tunnel.

[0021] The method for enumerating central devices in the GRE device group is as follows: b1. Each router in the GRE device group dynamically generates a unique ID number based on the current time as a random number; each router sends a message with its own device ID number to the other devices; b2. After receiving a message from other devices, each router device needs to reply with an ACK message, compare the ID number of the other devices with its own ID number, and update whether it should become the central device. If its own ID number is the largest, then the current device is updated to become the central device. After multiple rounds of b1 and b2 processes, a unique central terminal device is enumerated in the GRE device group.

[0022] In other embodiments, the ID number of the router device can be generated randomly and dynamically in other ways. When enumerating the central device, it can also be specified that the one with the smallest ID number is updated to the central device, or other rules can be used to enumerate the central device.

[0023] Methods for establishing GRE tunnels between the central terminal device and each sub-device include: c1. Create a virtual network interface of type GRE, and specify the local public IP address and the remote public IP address; c2. Configure the tunnel IP for the GRE virtual network port; c3. Add the GRE virtual network port and the LAN interface to the br bridge to establish a GRE tunnel between the central device and the sub-device.

[0024] In a GRE device group, each router device is connected to at least one terminal device. The connection between the terminal device and the router device is a Layer 2 network connection. The router devices communicate with each other through GRE tunnels to obtain public network addresses and terminal device addresses and establish a network neighbor table. The network neighbor table contains the addresses of all router devices and terminal devices. When communicating between router devices, between terminal devices, or between router devices and terminal devices, the address of the target device can be quickly obtained by querying the network neighbor table, simplifying the communication process and enabling fast communication.

[0025] If one or more terminal devices disconnect from the router, the existing network neighbor table is destroyed, and a new network neighbor table is rebuilt following the steps described above. Timely updates to the network neighbor table ensure normal and fast communication between devices.

[0026] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.

Claims

1. A multi-device GRE tunneling communication method, characterized in that, The process includes the following: a. Group at least some of the router devices on the network into GRE device groups, and interconnect the router devices in the GRE device groups with each other; b. Enumerate the central devices in the GRE device group. After successful enumeration, the remaining devices are sub-devices. c. A GRE tunnel is established between the central terminal device and each sub-device. The central terminal device receives messages from the sub-devices and replies to the messages, and the sub-devices receive messages from the central terminal device and reply to the messages, thereby enabling mutual communication. d. If the central device fails to respond within the timeout period, the central device is deemed abnormal, and the existing GRE tunnel is destroyed; repeat the above process a to c to re-establish the GRE tunnel; e. If the sub-device fails to respond within the timeout period, the sub-device is deemed abnormal, and the existing GRE tunnel is destroyed; repeat the above process a to c to re-establish the GRE tunnel; The router devices in the GRE device group are connected to at least one terminal device. The router devices obtain public network addresses and terminal device addresses through GRE tunnel communication and establish a network neighbor table. The terminal devices, router devices, or terminal devices and router devices obtain the addresses of communication objects by querying the network neighbor table and use the addresses to communicate. The terminal device and the router device are connected via a Layer 2 network connection. The network neighbor table includes the router device address and the terminal device address. After one or more terminal devices disconnect from the router device, the network neighbor table is re-established.

2. The multi-device GRE tunneling communication method as described in claim 1, characterized in that, The method for enumerating central devices in the GRE device group is as follows: b1. Each router in the GRE device group is assigned a unique ID number; each router sends a message with its own device ID number to the other devices; the comparison rules for the central device ID number are pre-configured; b2. Each router device receives a message from other devices, compares the ID number of the other devices with its own ID number, and if its own ID number matches the pre-set comparison rules, it updates the current device as the central device; After multiple rounds of b1 and b2 processes, a unique central device is enumerated in the GRE device group.

3. The multi-device GRE tunnel communication method as described in claim 2, characterized in that: In b1, the ID number of the router device is dynamically generated, and the ID number of the router device is dynamically generated based on the current time as a random number.

4. The multi-device GRE tunnel communication method as described in claim 2, characterized in that: The comparison rule for the central device ID is: the ID number is the largest or smallest at present.

5. The multi-device GRE tunneling communication method as described in claim 1, characterized in that: Router devices in a GRE device group are interconnected with each other via TCP.

6. The multi-device GRE tunneling communication method as described in claim 2, characterized in that: After receiving messages from other devices, the router needs to reply with an ACK message, compare the IDs of the other devices with its own ID, and update whether it has become a central device. The central devices that have been successfully enumerated periodically send messages to the sub-devices, the message content of which includes the ID and public IP address of the central device. After receiving the message, the sub-device needs to reply with an ACK message to indicate that the sub-device is currently working normally.

7. The multi-device GRE tunneling communication method as described in claim 1, characterized in that: The method for establishing GRE tunnels between the central terminal device and each sub-device includes: c1. Create a virtual network interface of type GRE, and specify the local public IP address and the remote public IP address; c2. Configure the tunnel IP for the GRE virtual network port; c3. Add the GRE virtual network port and the LAN interface to the br bridge to establish a GRE tunnel between the central device and the sub-device.

Citation Information

Patent Citations

  • Rapid flooding treatment method and rapid flooding treatment device

    CN104796339A

  • Network management method and device and electronic equipment

    CN116436755A