A method for customizing forwarding traffic for cloud workloads

Through the libpcap function library and the GRE universal routing encapsulation protocol, the blind spots and compatibility issues of traffic collection in the cloud environment are solved, the blind spot collection and forwarding of internal cloud traffic is realized, and the data acquisition capabilities of cloud security and operation and maintenance products are improved.

CN118573515BActive Publication Date: 2024-10-01BEIJING PAIWANG SOFTWARE CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411035661.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2024-10-01
Estimated Expiration
2044-07-31

AI Technical Summary

Technical Problem

Existing technologies are difficult to effectively collect and forward internal cloud traffic in a cloud environment, resulting in cloud security and operation and maintenance products being unable to obtain necessary raw traffic data, resulting in traffic collection blind spots and compatibility issues.

Method used

It uses the libpcap function library and the GRE universal routing encapsulation protocol, and uses packet capture and encapsulation technology to obtain and forward the traffic packets of the cloud host, achieving blind-spot collection and forwarding of traffic between virtual machines and between programs.

Benefits of technology

It achieves full collection and forwarding of internal traffic in the cloud environment, avoids traffic blind spots, simplifies deployment, eliminates compatibility issues, and provides a flexible traffic forwarding solution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118573515B_ABST
    Figure CN118573515B_ABST
Patent Text Reader

Abstract

The present invention belongs to the field related to cloud communication traffic management, and discloses a method for customized forwarding of cloud workload traffic. Compared with the existing technology, it is flexible to deploy, and any object that needs to collect and forward traffic can achieve related functions by deploying a simple, miniature traffic forwarding probe; there are no compatibility issues. Since the technologies used are relatively general technologies, users no longer need to worry about compatibility issues of practical methods; and the miniature diversion probe can provide richer capture and diversion conditions based on BPF conditions; at the same time, it completely eliminates the traffic collection and capture blind spots within the cloud environment, and realizes the collection and forwarding of traffic between virtual machines on the server, as well as the collection and forwarding of communication traffic between programs on the cloud host, avoiding the loss of source data for security and operation and maintenance products caused by the inability to obtain this part of the traffic.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field related to cloud communication traffic management, and specifically is a method for customized forwarding of cloud workload traffic. Background Art

[0002] In the field of security and operation and maintenance, there are many types of products that use traffic data as the analysis object to achieve various application scenarios. The way to obtain traffic is also relatively simple, that is, through the mirroring or splitting function of hardware network devices (such as switches), the traffic of all or specific ports is copied and sent to the security or operation and maintenance equipment connected to the mirroring port; but obviously, this method is not applicable in the cloud environment with software-defined networking. Not only can a lot of internal cloud traffic not be collected, but the relatively rigid mirroring strategy cannot adapt to the flexibility unique to the cloud environment.

[0003] In addition, because the traffic within the cloud environment often undergoes multiple encapsulations or NAT, even if the traffic in the cloud environment is mirrored, the complexity of its traffic data also places high demands on various products that use this traffic. Therefore, in order to implement various cloud security or cloud operation and maintenance scenarios in the cloud environment, it is necessary to divert the traffic within the cloud through some method and deliver it to related products that need this original traffic to implement security and operation and maintenance scenarios. Summary of the invention

[0004] The object of the present invention is to provide a method for customized forwarding of cloud workload traffic to solve the problems raised in the above background technology.

[0005] To achieve the above object, the present invention provides the following technical solutions:

[0006] A method for customizing forwarding cloud workload traffic includes the following steps:

[0007] Based on the data packet capture function library, the traffic of the host host network card is obtained, and the data packet capture function library selects the libpcap function library;

[0008] Based on the GRE general routing encapsulation protocol, the traffic data packet of the host host is encapsulated and added into the GRE encapsulation transport protocol to generate a data packet message and forward it;

[0009] The receiving end receives the encapsulated and forwarded data packets through the GRE Tunnel interface, analyzes the IP header to confirm whether the destination address matches the receiving end. If it matches, the data packet is received and decapsulated through the GRE protocol.

[0010] As a further solution of the present invention: the libpcap function library is arranged between the upper layer application and the network interface, and the libpcap function library includes the functions:

[0011] Packet capture: used to capture the original data packets passing through the network card;

[0012] Custom data packet sending: used to construct raw data packets in any format;

[0013] Traffic collection and statistics: used to collect traffic information in the network;

[0014] Rule filtering: used to support built-in rule filtering and establish filtering rules based on demand.

[0015] As a further solution of the present invention:

[0016] As a further solution of the present invention: the libpcap function library is a user-level API interface independent of system settings, and the libpcap function library is used to provide a portable framework for underlying network detection. The basic parameter data captured by the data packet capture program based on the libpcap function library includes:

[0017] For a specific network card, obtain traffic capture of all network cards;

[0018] For IP, IP:port capture;

[0019] For Subnet, IP~IP capture;

[0020] and bytecode-based capture.

[0021] As a further solution of the present invention: the step of obtaining the traffic of the host host network card based on the data packet capture function library specifically includes:

[0022] Use the pcap_lookupdev() function to find network devices, obtain available network cards, and return a list of pointers to network device names when there are multiple network cards.

[0023] Select the network card object to be used based on the pointer list, open the network card through the pcap_open_live() function, and return the number of seconds used to capture network data packets;

[0024] Get the network parameters through pcap_lookupnet() to obtain the IP address and subnet mask of the specified network device;

[0025] Compile the filtering strategy through pcap_compile(), and set the filter through pcap_setfilter() function to filter the data packet;

[0026] The data packet is captured through a callback function, which may be a combination of a pcap_loop() function and a pcap_dispatch() function or a combination of a pcap_next() function and a pcap_next_ex() function.

[0027] As a further solution of the present invention: the GRE general routing encapsulation protocol defines encapsulating another protocol on a network layer protocol, wherein the protocols may be the same, and the GRE general routing encapsulation protocol adopts the tunnel technology between protocol layers.

[0028] As a further solution of the present invention: the step of encapsulating the traffic data packet of the host host based on the GRE general routing encapsulation protocol, adding the GRE encapsulation transport protocol to generate a data packet message and forwarding it specifically includes:

[0029] Create a GRE socket in the program for sending function calls;

[0030] When the received data packet needs to be forwarded, the Ethernet header of the data packet is removed, and the GRE encapsulation transport protocol is added before the IP header, and the send function is called to send it out.

[0031] Compared with the prior art, the beneficial effects of the present invention are: compared with the prior art, the deployment is flexible, and for any object that needs to collect and forward traffic, the relevant functions can be realized by deploying a simple, miniature traffic forwarding probe; there are no compatibility issues. Since the technologies adopted are relatively general technologies, users no longer need to worry about the compatibility issues of practical methods; and the miniature diversion probe can provide richer capture and diversion conditions based on BPF conditions; at the same time, it completely eliminates the traffic collection and capture blind spots within the cloud environment, realizes the collection and forwarding of traffic between virtual machines on the server, and the collection and forwarding of communication traffic between programs on the cloud host, avoiding the loss of source data of security and operation and maintenance products caused by the inability to obtain this part of the traffic. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 A process for customizing a method for forwarding cloud workload traffic.

[0033] Figure 2 Schematic diagram of the working of libpcap in a customized method of forwarding cloud workload traffic.

[0034] Figure 3 A schematic diagram of a method for using GRE in a customized method for forwarding cloud workload traffic with reference to the prior art.

[0035] Figure 4A schematic diagram of an encapsulated data packet message in a customized method for forwarding cloud workload traffic. DETAILED DESCRIPTION

[0036] 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 the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0037] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments.

[0038] In order to solve the problems in the background technology, the mainstream virtual switch components of the cloud architecture in the prior art are specially designed with SPAN, RSPAN and ERSPAN cloud traffic diversion functions to output all or part of the traffic flowing through the virtual switch to a specific receiving end. The following briefly introduces the definitions and differences of these three methods:

[0039] SPAN: Using the function provided by the port mirroring (SPAN) of the virtual switch, users can copy the messages of the specified port to another port on the switch connected to a network monitoring device for network monitoring and troubleshooting; SPAN does not affect the message exchange between the source port and the destination port, but only copies all the messages entering and output from the source port to the destination port as is. However, if the mirrored traffic exceeds the bandwidth of the destination port, for example, a 100Mbps destination port monitors the traffic of a 1000Mbps source port, the message may be discarded; the biggest disadvantage of this method is that it is not applicable to cloud environments in principle, so it is rarely used in practice.

[0040] RSPAN: Remote SPAN is an extension of local SPAN. It breaks the limitation that the source port and the destination port must be on the same device, and allows the source port and the destination port to span multiple network devices.

[0041] The function of RSPAN is to transmit all mirrored packets to the destination port of the remote mirroring device through a special RSPAN VLAN (called Remote VLAN). The roles of the device are divided into three types:

[0042] (1) Source switch: The switch where the remote mirroring source port is located is responsible for copying the message of the source port and outputting it from the output port of the source switch, forwarding it through the Remote VLAN, and transmitting it to the intermediate switch or the destination switch.

[0043] (2) Intermediate switch: A switch between the source switch and the destination switch in the network that transmits the mirrored message to the next intermediate switch or the destination switch through RemoteVLAN. If the source switch and the destination switch are directly connected, there is no intermediate switch.

[0044] (3) Destination switch: The switch where the remote mirroring destination port is located forwards the mirrored packets received from the Remote VLAN to the monitoring device through the mirroring destination port.

[0045] Objectively speaking, RSPAN already has application value that meets the cloud environment scenario, but its special RSPAN VLAN has limited the deployment and use of this technology to a certain extent.

[0046] ERSPAN: Enhanced Remote SPAN is an extension of RSPAN. In common remote port mirroring, mirrored data packets can only be transmitted within the second layer and cannot pass through the routed network, but in encapsulated remote port mirroring, mirrored packets can be transmitted between routed networks.

[0047] The function implemented by ERSPAN is to encapsulate all mirrored packets into IP packets through a GRE tunnel and route them to the destination port of the remote mirroring device. The roles of the device are divided into two types:

[0048] (1) Source switch: The switch where the remote mirroring source port is located is responsible for copying the message from the source port and outputting it from the output port of the source switch, encapsulating it into an IP message through GRE and forwarding it to the destination switch.

[0049] (2) Destination switch: The switch where the remote mirroring destination port is located will receive the mirrored message through the mirroring destination port, decapsulate the GRE message, and then forward it to the monitoring device.

[0050] Destination switch: The switch where the remote mirroring destination port is located will receive the mirrored message through the mirroring destination port, decapsulate the GRE message, and then forward it to the monitoring device. Compared with RSPAN, ERSPAN uses the more common GRE tunnel protocol as the carrier for encapsulation and forwarding, so it is more flexible, more practical, and has the best applicability. It is also one of the more common methods used in public clouds and medium and large private clouds.

[0051] Since SPAN / RSPAN / ERSPAN can be implemented based on the virtual switch in the cloud environment, it can, to a certain extent, solve the source data acquisition problem of cloud security and cloud operation and maintenance products that analyze cloud traffic for a period of time. However, with the continuous development of cloud technology, the SPAN / RSPAN / ERSPAN method based on virtual switch technology has gradually exposed some unavoidable problems, mainly reflected in:

[0052] (1) There are blind spots in data collection. It is impossible to collect traffic of various workloads within a cloud host. For example, the communication traffic between various programs within a cloud host, or the communication traffic between PODs based on container technology within a cloud host. Even the communication between two virtual machines within a server does not go through a virtual switch. In short, the SPAN / RSPAN / ERSPAN method has many blind spots in data collection, which also causes great trouble for the security and operation and maintenance products connected to it, because the traffic data missing from the collection blind spots is often the most hidden risk point in cloud security or cloud operation and maintenance scenarios.

[0053] (2) Complexity and compatibility of functional implementation: Since virtual switches are typical SDN components, the compatibility of various versions and the functional inconsistency caused by software iterations lead to extremely complex operations and frequent abnormal situations when implementing the SPAN / RSPAN / ERSPAN method based on virtual switches.

[0054] (3) Resource consumption of virtual switches: When SPAN / RSPAN / ERSPAN is actually running, it will consume the computing resources of the virtual switch according to the amount of traffic that needs to be diverted. However, the virtual switch software does not have strict algorithmic restrictions on the resource consumption of the three functions of SPAN / RSPAN / ERSPAN. Therefore, for virtual switches that need to handle large traffic or large fluctuations, there is a certain risk in enabling the SPAN / RSPAN / ERSPAN function. Therefore, in actual work, many engineers are reluctant to enable these additional functions.

[0055] In summary, due to the obvious defects of the three methods of SPAN / RSPAN / ERSPAN, we believe that these three methods are only suitable for the traffic diversion needs of the north-south gateway location of the cloud service, and are not suitable for the traffic diversion needs of the internal cloud traffic and the east-west traffic, especially the traffic diversion needs between virtual machines in the server and the traffic diversion needs between programs in the cloud host; therefore, this method will discuss the solution of how to divert traffic without blind spots within the cloud service, and focus on solving the traffic diversion problems between virtual machines in the server and the traffic diversion problems between programs in the cloud host.

[0056] like Figure 1 The above is a customized method for forwarding cloud workload traffic provided by an embodiment of the present invention. This solution implements the blind spot-free traffic diversion requirements for traffic within the cloud service, between virtual machines of the server, and between cloud host programs by implanting a dedicated, self-designed diversion probe program into a server or cloud host that needs to be diverted. The method includes the following steps:

[0057] S10, based on the data packet capture function library, obtaining the traffic of the host host network card, the data packet capture function library selects the libpcap function library.

[0058] S20, encapsulating the traffic data packet of the host host based on the GRE general routing encapsulation protocol and adding the GRE encapsulation transport protocol to generate a data packet message and forward it.

[0059] S30, the receiving end receives the encapsulated and forwarded data packet through the GRE Tunnel interface, analyzes the IP header to confirm whether the destination address matches the receiving end, and if so, receives the data packet and decapsulates it through the GRE protocol.

[0060] In this embodiment, there are two main methods for obtaining the host network card traffic, one is based on the libpcap data packet capture function library, and the other is based on ebpf; among them, libpcap is the most common data packet collection method, and ebpf is a relatively hot method in recent years. However, in order to reduce the complexity of the program and improve compatibility, we use the most common libpcap method, among which the usage method of Libpcap is:

[0061] The C function interface provided by the Libpcap library is used to capture data packets passing through a specified network interface. The interface should be set to promiscuous mode. Libpcap provides a user-level network packet capture interface and fully considers the portability of applications. Libpcap can run on most Linux platforms. On the Windows platform, there is also a development library with similar functions: Wincap.

[0062] As another preferred embodiment of the present invention, described libpcap function library is arranged between upper layer application program and network interface, and described libpcap function library comprises function:

[0063] Packet capture: used to capture the original data packets passing through the network card;

[0064] Custom data packet sending: used to construct raw data packets in any format;

[0065] Traffic collection and statistics: used to collect traffic information in the network;

[0066] Rule filtering: used to support built-in rule filtering and establish filtering rules based on demand.

[0067] In this embodiment, based on the above main functions, the application scope of libpcap is very wide, and typical applications include network protocol analyzers, network traffic generators, network intrusion detection systems, network scanners and other security tools.

[0068] like Figure 2 As shown, as another preferred embodiment of the present invention, the libpcap function library is a user-level API interface independent of system settings, and the libpcap function library is used to provide a portable framework for underlying network detection. The basic parameter data captured by the data packet capture program based on the libpcap function library includes:

[0069] For a specific network card, obtain traffic capture of all network cards;

[0070] For IP, IP:port capture;

[0071] For Subnet, IP~IP capture;

[0072] and bytecode-based capture.

[0073] In this embodiment, as a library for capturing network data packets, it is a user-level API interface independent of the system, providing a portable framework for underlying network detection; the capture of a packet is divided into three main parts, including underlying packet capture, middle-layer packet filtering, and application-layer user interface. This is the same as the processing flow of the Linux operating system for data packets (network card->network card driver->data link layer->IP layer->transport layer->application); the packet capture mechanism is to add a bypass process at the data link layer (which does not interfere with the processing of the system's own network protocol stack), filter and buffer the sent and received data packets through the Linux kernel, and finally pass them directly to the upper-layer application.

[0074] As another preferred embodiment of the present invention, the step of acquiring the traffic of the host network card based on the data packet capture function library specifically includes:

[0075] Use the pcap_lookupdev() function to find network devices, obtain available network cards, and return a list of pointers to network device names when there are multiple network cards.

[0076] Select the network card object to be used based on the pointer list, open the network card through the pcap_open_live() function, and return the number of seconds used to capture network data packets;

[0077] Get the network parameters through pcap_lookupnet() to obtain the IP address and subnet mask of the specified network device;

[0078] Compile the filtering strategy through pcap_compile(), and set the filter through pcap_setfilter() function to filter the data packet;

[0079] The data packet is captured through a callback function, which may be a combination of a pcap_loop() function and a pcap_dispatch() function or a combination of a pcap_next() function and a pcap_next_ex() function.

[0080] like Figure 3 As shown, as another preferred embodiment of the present invention, the GRE general routing encapsulation protocol defines encapsulating another protocol on a network layer protocol, wherein the protocols may be the same, and the GRE general routing encapsulation protocol uses tunnel technology between protocol layers.

[0081] In this embodiment, GRE (Generic Routing Encapsulation): Generic Routing Encapsulation Protocol, was first used in the field of routing switching. GRE defines encapsulating another protocol (or the same protocol) on a network layer protocol. GRE is the third layer tunnel protocol of VPN (Virtual Private Network), that is, a technology called Tunnel is used between protocol layers.

[0082] like Figure 4 As shown, as another preferred embodiment of the present invention, the steps of encapsulating the traffic data packet of the host host based on the GRE general routing encapsulation protocol, adding the GRE encapsulation transport protocol to generate a data packet message and forwarding it specifically include:

[0083] Create a GRE socket in the program for sending function calls;

[0084] When the received data packet needs to be forwarded, the Ethernet header of the data packet is removed, and the GRE encapsulation transport protocol is added before the IP header, and the send function is called to send it out.

[0085] In this embodiment, the standard use scenario of GRE is the tunnel communication scenario in the field of network routing; but there are few applications at the host level. In this method, we will use the GRE protocol in the application scenario of the server or cloud host to help us realize the forwarding of all or specific traffic of the server or cloud host. In specific use, the program receives a data packet (received through libpcap); when forwarding is required, the Ethernet header of the data packet (the first 14 bytes, followed by the IP header) is removed, and the gre header (18 bytes, the first two bytes are 0x65 and 0x58, the next four are the ID number, and the rest are reserved) is added to the front of the IP header, and then send is called to send. In addition, for the aforementioned step S10, the decapsulation process is opposite to the encapsulation process. The receiving end receives the message from the GRE tunnel interface, analyzes the IP header and finds that the destination address of the message is this device, then the receiving end removes the IP header and hands it over to the GRE protocol for processing. The GRE protocol strips the GRE header, obtains the X protocol, and then hands it over to the X protocol for subsequent forwarding processing of this data message. In the cloud environment, the implementation of decapsulation is usually completed in the network protocol stack of the cloud host.

[0086] Compared with the existing SPAN / RSPAN / ERSPAN based on virtual switches, the biggest technical advantages of using the host's probe program to forward all or part of the host's traffic in real time through the GRE protocol are:

[0087] (1) Flexible deployment: For any object that requires traffic collection and forwarding, the relevant functions can be achieved by deploying a simple, miniature traffic forwarding probe.

[0088] (2) No compatibility issues; since the technologies used are relatively common technologies, such as libpcap and GRE protocols, which are widely used methods, users no longer need to worry about compatibility issues of practical methods.

[0089] (3) Richer customization functions: Compared with SPAN / RSPAN / ERSPAN based on virtual switches, this micro diversion probe can provide richer capture and diversion conditions based on BPF conditions.

[0090] (4) Most importantly, it completely eliminates the blind spots of traffic collection and capture within the cloud environment; it realizes the collection and forwarding of traffic between virtual machines on the server, as well as the collection and forwarding of communication traffic between programs on the cloud host; thereby avoiding the loss of source data for security and operation and maintenance products due to the inability to obtain this part of the traffic. It is a practical and beneficial supplement and improvement to existing technical methods.

[0091] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and 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-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an 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 (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0092] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the disclosure in the specification and examples. This application is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.

[0093] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A method for customized forwarding of cloud workload traffic, characterized in that: The following steps are involved: Based on the data packet capture function library, the traffic of the host host network card is obtained, and the data packet capture function library selects the libpcap function library; Based on the GRE general routing encapsulation protocol, the traffic data packet of the host host is encapsulated and added into the GRE encapsulation transport protocol to generate a data packet message and forward it; The receiving end receives the encapsulated and forwarded data packets through the GRE Tunnel interface, analyzes the IP header to confirm whether the destination address matches the receiving end. If it matches, the data packet is received and decapsulated through the GRE protocol. The libpcap library is arranged between the upper layer application and the network interface, and the libpcap library includes the following functions: Packet capture: used to capture the original data packets passing through the network card; Custom data packet sending: used to construct raw data packets in any format; Traffic collection and statistics: used to collect traffic information in the network; Rule filtering: used to support built-in rule filtering and establish filtering rules based on demand selection; The libpcap library is a user-level API interface independent of system settings. The libpcap library is used to provide a portable framework for underlying network detection. The basic parameter data captured by the data packet capture program based on the libpcap library includes: For network cards, obtain traffic capture of all network cards; For IP, IP:port capture; For Subnet, IP~IP capture; And bytecode-based capture; The step of obtaining the traffic of the host network card based on the data packet capture function library specifically includes: Use the pcap_lookupdev() function to find network devices, obtain available network cards, and return a list of pointers to network device names when there are multiple network cards. Select the network card object to be used based on the pointer list, open the network card through the pcap_open_live() function, and return the number of seconds used to capture network data packets; Get the network parameters through pcap_lookupnet() to obtain the IP address and subnet mask of the specified network device; Compile the filtering strategy through pcap_compile(), and set the filter through pcap_setfilter() function to filter the data packet; The data packet is captured by a callback function, wherein the callback function is a combination of a pcap_loop() function and a pcap_dispatch() function or a combination of a pcap_next() function and a pcap_next_ex() function.

2. A method for customized forwarding of cloud workload traffic according to claim 1, characterized in that: The GRE general routing encapsulation protocol defines encapsulating another protocol on a network layer protocol, wherein the protocols are the same, and the GRE general routing encapsulation protocol adopts the tunnel technology between protocol layers.

3. A method for customized forwarding of cloud workload traffic according to claim 2, characterized in that: The step of encapsulating the traffic data packet of the host host based on the GRE general routing encapsulation protocol, adding the GRE encapsulation transport protocol to generate a data packet message and forwarding it specifically includes: Create a GRE socket in the program for sending function calls; When the received data packet needs to be forwarded, the Ethernet header of the data packet is removed, and the GRE encapsulation transport protocol is added before the IP header, and the send function is called to send it out.