A data forwarding method and device, electronic equipment and readable storage medium
By using an extended filter (eBPF) at the injection point of the traffic controller to bypass the kernel protocol stack, efficient replication and forwarding of traffic data is achieved, solving the problem of excessive gateway load, improving data replication and forwarding efficiency, and reducing costs.
Patent Information
- Application Number
- CN202210575433.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-25
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2042-05-25
AI Technical Summary
In existing technologies, the replication and forwarding of traffic data are costly and inefficient, especially with excessive load at the gateway, resulting in significant performance consumption.
By calling the extended filter (eBPF) at the injection point of the flow controller to copy the initial traffic data, the process of establishing a connection with the transmission control protocol is bypassed, the kernel protocol stack is bypassed, and the packets are forwarded to the test server through the Internet Protocol IP tunnel.
It improves the efficiency of traffic data replication and forwarding, reduces gateway load, lowers costs, and ensures that the test server performs accurate business tests based on real traffic data.
Smart Images

Figure CN115695256B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, in particular to a data forwarding method and device, electronic equipment and readable storage medium. BACKGROUND
[0002] At present, with the continuous development of application programs, the demand of each application background for the flow playback technology is increasing, and the flow playback technology can copy the online real traffic data of the application to the test server to complete various test tasks. At present, the function module for completing the traffic data replication is located in the gateway, and the traffic data is copied and forwarded based on the 7-layer network protocol, which will increase the load of the gateway and consume a lot of performance.
[0003] Therefore, there is a problem of high cost and low efficiency in the replication and forwarding of traffic data. SUMMARY
[0004] The purpose of the embodiment of the present application is to provide a data forwarding method, device, electronic equipment and readable storage medium, which can improve the efficiency of traffic data replication and forwarding and save cost. The specific technical solutions are as follows:
[0005] In the first aspect of the present application, a data forwarding method is first provided, comprising:
[0006] receiving initial traffic data sent by a source server, the initial traffic data being data collected by the source server from a user terminal;
[0007] calling an extended filter to replicate the initial traffic data to obtain a first data packet, the extended filter being arranged at an injection point of a traffic controller, and the traffic controller being connected with a gateway network;
[0008] forwarding the first data packet to a test server through an Internet Protocol (IP) tunnel, so that the test server tests a preset service based on test traffic data in the first data packet.
[0009] In the second aspect of the present application, a data forwarding device is further provided, comprising:
[0010] a receiving module configured to receive initial traffic data sent by a source server, the initial traffic data being data collected by the source server from a user terminal;
[0011] a replication module configured to call an extended filter to replicate the initial traffic data to obtain a first data packet, the extended filter being arranged at an injection point of a traffic controller, and the traffic controller being arranged on a gateway;
[0012] The forwarding module is configured to forward the first data packet to the test server through an Internet Protocol (IP) tunnel, so that the test server tests the preset service based on the test traffic data in the first data packet.
[0013] In yet another aspect of the present application, a computer readable storage medium is provided, which stores instructions that, when executed on a computer, cause the computer to perform any of the above-described data forwarding method or data testing method.
[0014] In yet another aspect of the present application, a computer program product is provided, which contains instructions that, when executed on a computer, cause the computer to perform any of the above-described data forwarding method or data testing method.
[0015] The data forwarding method provided by the embodiments of the present application copies the initial traffic data sent by the source server through the extension filter set at the injection point of the traffic controller to obtain the first data packet, where the process of establishing a connection with the Transmission Control Protocol is omitted, and the kernel protocol stack is bypassed. Therefore, the initial traffic data is copied through the extension filter, the first data packet can be efficiently obtained, and the load of the gateway is reduced. Then, the first data packet is forwarded to the test server through an Internet Protocol (IP) tunnel, so that the test server tests the preset service based on the test traffic data in the first data packet. In this way, the problem of high cost and low efficiency in the current replication and forwarding of traffic data is solved, the load of the gateway is reduced, and thus the efficiency of the replication and forwarding of traffic data can be improved and the cost can be saved. BRIEF DESCRIPTION OF DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows.
[0017] Figure 1 is a structure schematic diagram of a data forwarding device provided by the embodiments of the present application;
[0018] Figure 2 is a flowchart of a data forwarding method provided by the embodiments of the present application;
[0019] Figure 3 is a flowchart of a data testing method provided by the embodiments of the present application;
[0020] Figure 4 is a structure schematic diagram of a data forwarding device provided by the embodiments of the present application;
[0021] Figure 5 is a structure schematic diagram of a data testing device provided by the embodiments of the present application;
[0022] Figure 6 Fig. 1 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0023] The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
[0024] The data forwarding method provided by the embodiments of the present application can be applied to at least the following application scenarios, which are described below.
[0025] Currently, with the continuous development of application programs, the demand of various applications for flow playback technology is increasing. The flow playback technology is a technology for copying real traffic on a business line to a test server. It is used to complete various test tasks, such as A / B testing and stress testing functions. Among them, A / B testing is to develop two schemes (such as two pages) for the same goal, let a part of users use the A scheme, and another part of users use the B scheme, record the use of the users, and determine which scheme is more in line with the design goal. These test tasks are to optimize application performance.
[0026] Before completing these test tasks, copying real traffic data on the line is a prerequisite for implementing the above tests. This process has no impact on the online business and the performance consumption is as low as possible.
[0027] Currently, the function module for completing traffic data copying is located in the gateway. Since the gateway itself has a heavy load, in the process of copying and forwarding traffic data, it needs to be copied and forwarded based on the 7-layer Open System Interconnection Reference Model (OSI). In this process, the overhead of establishing a connection, context switching overhead, user-kernel state copying overhead, etc. will undoubtedly increase the load of the gateway. The OSI is an open communication system interconnection reference model, which is a protocol specification with a 7-layer structure. From top (7th layer) to bottom (1st layer), it is the application layer, presentation layer, session layer, transport layer, network layer, data link layer and physical layer. Among them, the high layer (i.e. 7, 6, 5, 4 layer) defines the function of the application program; the lower 3 layers (i.e. 3, 2, 1 layer) mainly face the end-to-end, point-to-point data flow through the network.
[0028] Therefore, the current copying of traffic data on the line has the problems of high cost and low efficiency.
[0029] Based on the above application scenario, the data forwarding method provided by the embodiments of the present application will be described in detail.
[0030] This invention proposes a data forwarding method based on extended filter (eBPF).
[0031] like Figure 1 As shown, an Application Programming Interface Gateway (API Gateway) is a server cluster that encapsulates the internal system architecture of an application. First, during the gateway's packet sending process, initial traffic data is converted into Transmission Control Protocol (TCP) packets via a socket interface, then into Internet Protocol (IP) packets, and finally transmitted asynchronously and concurrently through the network interface card to the business backend server or test server. Asynchronous concurrency refers to multiple asynchronous requests simultaneously obtaining the final result.
[0032] The data packets containing initial traffic data sent by the gateway enter the kernel protocol stack. Before being passed to the network interface card (NIC), the eBPF program selects whether to copy the data packets containing the initial traffic data and forward them according to preset rules. eBPF is a program injected at the injection point of the traffic controller. The traffic controller is network-connected to the gateway, meaning it can communicate with the gateway. The injection point of eBPF in the gateway's data packet sending process is as follows: Figure 1 As shown.
[0033] The user-space agent provides the task of receiving and copying remote procedure calls, and inserts this task into the rules of the extended filter. Since the flow controller performs flow control at the output port of the application interface gateway, the extended filter set at the injection point of the flow controller can detect the data packet when it passes through the output port. If it is determined that the data packet containing the initial flow data needs to be copied and forwarded, the initial flow data will be copied by calling the extended filter set at the injection point of the flow controller, obtaining the first data packet. Here, the process of establishing a connection with the transmission control protocol is omitted, bypassing the kernel protocol stack. Therefore, copying the initial flow data through the extended filter can efficiently obtain the first data packet and reduce the gateway load. Then, the first data packet is forwarded to the test server through an Internet Protocol (IP) tunnel, so that the test server can test the preset service based on the test flow data in the first data packet.
[0034] This solves the current problems of high cost and low efficiency in copying and forwarding traffic data, reduces the gateway load, and thus improves the efficiency of copying and forwarding traffic data while saving costs.
[0035] For the test server, test traffic data is obtained by parsing the first data packet sent by the gateway. Preset services are then tested based on the test traffic data. This allows for more authentic testing based on real online traffic data, thereby improving service performance.
[0036] The following is combined with Figure 2 The data forwarding method provided in the embodiments of the present invention will be described in detail.
[0037] Figure 2 This is a flowchart of a data forwarding method provided in an embodiment of the present invention;
[0038] like Figure 2 As shown, this data forwarding method may include steps 210-230 and is applied to a gateway, as detailed below:
[0039] Step 210: Receive initial traffic data sent by the source server. The initial traffic data is the data collected by the source server from the user terminal.
[0040] Step 220: Call the extended filter to copy the initial traffic data to obtain the first data packet. The extended filter is set at the injection point of the traffic controller, and the traffic controller is connected to the gateway network.
[0041] Step 230: The first data packet is forwarded to the test server through the Internet Protocol (IP) tunnel, so that the test server can test the preset service based on the test traffic data in the first data packet.
[0042] In summary, in this embodiment of the invention, the initial traffic data sent by the source server is copied by calling the extended filter set at the injection point of the traffic controller to obtain the first data packet. Here, the process of establishing a connection with the Transmission Control Protocol is omitted, and the kernel protocol stack is bypassed. Therefore, copying the initial traffic data through the extended filter can efficiently obtain the first data packet and reduce the gateway load. Then, the first data packet is forwarded to the test server through the Internet Protocol (IP) tunnel, so that the test server can test the preset service based on the test traffic data in the first data packet. In this way, the problems of high cost and low efficiency in the current copying and forwarding of traffic data are solved, the gateway load is reduced, and thus the efficiency of copying and forwarding traffic data can be improved and costs saved.
[0043] The specific implementation methods for each of the above steps are described below.
[0044] First, step 210 is involved.
[0045] Step 210: Receive initial traffic data sent by the source server. The initial traffic data is the data collected by the source server from the user terminal.
[0046] The goal of this invention is to copy the actual traffic on the business line and forward it. Therefore, it is first necessary to receive the initial traffic data sent by the source server.
[0047] Next, step 220 is involved.
[0048] Step 220: Call the extended filter to copy the initial traffic data to obtain the first data packet. The extended filter is set at the injection point of the traffic controller.
[0049] It should be noted that the process in this embodiment of the invention occurs during the gateway packet sending process. Before step 220, layer 7 load balancing has been completed and a matching gateway rule for data sending has been found.
[0050] Network load balancing involves symmetrically arranging multiple servers into a server array. Each server has equal status and can independently provide services without the assistance of other servers. Through load sharing techniques, incoming requests are evenly distributed across one of the servers in this symmetrical structure, and the server receiving the request responds independently to the client's request. Load balancing can evenly distribute client requests across the server array, thereby providing fast access to important data and resolving issues related to high-concurrency access.
[0051] The extended filter is located at the injection point of the flow controller. A brief explanation of the flow controller follows:
[0052] Traffic Control (TC) is used for traffic control in the Linux kernel, primarily by establishing a queue at the output port. Traffic control is ultimately performed within the kernel; TC controls traffic on network devices based on different algorithms.
[0053] The following is a brief explanation of extended filters:
[0054] Extended BPF (eBPF) is a type of extended BPF. eBPF is an assembly-like language that allows writing secure programs that run in the kernel. eBPF programs can attach to several injection points in the kernel. An eBPF program is attached to a specified kernel code path; when that code path is executed, the corresponding eBPF program is executed.
[0055] The original Berkeley Packet Filter (BPF) was designed to capture and filter network packets that conform to specific rules. The filter provides raw link-layer packet transmission and reception for programs running on register-based virtual machines.
[0056] For example, the data packet sent by the gateway, including initial traffic data, enters the kernel protocol stack. Using a queuing rule in the traffic controller, the eBPF program can be injected into the traffic controller's egress rule. At this point, the data packet has passed through the protocol stack and entered the device layer.
[0057] Therefore, eBPF-based Layer 3 forwarding bypasses the kernel protocol stack, eliminating the need for the previous layer-by-layer transmission process from upper to lower layers and the need to establish a connection with the Transmission Control Protocol. Thus, by copying initial traffic data through extended filters, the first data packet can be obtained efficiently, reducing the gateway load. This bypass, specifically full kernel bypass, is a user-space network stack technique designed to bypass the kernel and directly utilize network hardware from user-space processes.
[0058] The kernel protocol stack is the most fundamental part of the operating system. It is a piece of software that provides secure access to computer hardware for numerous applications. This access is limited, and the kernel determines when a program can operate on a particular part of the hardware and for how long.
[0059] A protocol stack refers to the sum of all layers of protocols in a network, reflecting the data transmission process within a network: from upper-layer protocols to lower-layer protocols, and then from lower-layer protocols to upper-layer protocols. For example, a Hypertext Transfer Protocol (HTTP) request is first converted into TCP packets, then into IP packets (HTTP->TCP->IP), and then transmitted through the network card. The receiving end receives the IP packets through the network card, removes the IP header, detects that it is a TCP packet, and then passes the TCP packet to the TCP protocol processing layer. If it detects that it is an HTTP packet, it passes the HTTP packet to the HTTP protocol processing layer.
[0060] TCP is a connection-oriented, reliable, byte-stream-based transport layer communication protocol. TCP is designed to adapt to layered protocol hierarchies that support multiple network applications.
[0061] HTTP is a simple request-response protocol that typically runs on top of TCP. It specifies what messages a client might send to a server and what responses it might receive.
[0062] IP, or Internet Protocol, is a set of protocols designed for communication between interconnected computer networks. In the Internet, it is a set of rules that enables all computer networks connected to the network to communicate with each other, specifying the rules that computers must follow when communicating on the Internet.
[0063] All network data is transmitted through layers of protocols stacked together, like a stack, hence the name protocol stack.
[0064] Specifically, step 220 may include the following steps:
[0065] Invoke the extended filter so that it determines the test traffic data from the initial traffic data according to the pre-set filtering rules;
[0066] Copy the test traffic data to obtain the first data packet.
[0067] Specifically, the eBPF program is invoked to determine the test traffic data from the initial traffic data according to the filtering rules in the pre-set map mechanism, and the test traffic data hit from the initial traffic data is copied to obtain the first data packet.
[0068] Here, map can be a rule defined by the user kernel, and it can exist in the form of a hash table.
[0069] For example, test traffic data that is matched from the initial traffic data is copied based on the filtering information (e.g., dst-ip) stored in the map, where dst-ip is the destination IP address. Path X is followed whenever the destination address is X.
[0070] The step of copying test traffic data to obtain the first data packet, as mentioned above, may specifically include the following steps:
[0071] Obtain the preset data structure, which includes: structure parameters and protocol header;
[0072] The protocol header is used to store the protocol header information of each layer, so that the second data packet can be transmitted between the different layers of the protocol.
[0073] Based on the structural parameters, test traffic data and protocol header information are stored to obtain the first data packet.
[0074] During the transmission of the first data packet containing test traffic data between different protocol layers, the header of each protocol layer is inserted before the user data (i.e., the test traffic data). Correspondingly, address pointers describing the protocol header information are assigned values in a predefined data structure. The protocol header information is used for the transmission of the first data packet between different protocol layers. Structure parameters are used to manage and control information related to the data packet, such as address information.
[0075] The aforementioned preset data structure can be a socket buffer (sk_buff).
[0076] The socket buffer structure is an important data structure in network code, managing and controlling information for receiving or sending data packets. It represents a message to be sent or processed and persists throughout the entire protocol stack.
[0077] The socket buffer consists of message data and management data:
[0078] Among them, the message data stores the data that is actually transmitted in the network, that is, the test traffic data involved in this invention.
[0079] Management data, in particular, is additional data used by the kernel to process messages. This data constitutes the control information exchanged between protocols. It includes: structure parameters and protocol headers.
[0080] Specifically, the step of invoking the extended filter to determine test traffic data from the initial traffic data according to pre-set filtering rules may include the following steps:
[0081] The filter function stored in the extended filter is invoked to execute the pre-set filter rules and determine the test traffic data from the initial traffic data.
[0082] Since eBPF programs cannot arbitrarily call kernel functions, they need to call the filtering functions stored in the extended filter (such as the bpf helper function) to copy the test traffic data from the initial traffic data according to the filtering rules.
[0083] Finally, step 230 is involved.
[0084] Step 230: The first data packet is forwarded to the test server through the Internet Protocol (IP) tunnel, so that the test server can test the preset service based on the test traffic data in the first data packet.
[0085] IP tunneling technology is a process by which a router encapsulates one network layer protocol into another protocol for transmission across a network to another router. It can encapsulate the original IP packet (whose header contains the original sender and final destination) within the payload of another data packet (called an encapsulated IP packet) for transmission.
[0086] Current IP tunneling technologies include: IP in IP (IPIP), minimal encapsulation, and generic routing encapsulation.
[0087] An IP tunnel consists of a transmission channel, an encapsulation component, and a decapsulation component. The transmission channel is responsible for transmitting data packets, the encapsulation component is responsible for sending data packets, and the decapsulation component is responsible for receiving data packets. Here, the IP tunnel is responsible for forwarding the first data packet to the test server.
[0088] In one possible embodiment, the following steps may be included prior to step 230:
[0089] Based on the tunnel identifier information of the IP tunnel, the first data packet is encapsulated to obtain the second data packet;
[0090] Accordingly, step 230 may specifically include the following steps:
[0091] The second data packet is forwarded to the test server via an IP tunnel.
[0092] When a filtering function (such as the BPF helper function) copies the socket cache data structure, it only copies the metadata. The original packets share the same underlying data, so the packet data cannot be modified, and therefore cannot be forwarded via routing. Here, IPIPtunnel encapsulates the first data packet into a second data packet based on the IP tunnel's tunnel identifier information, and then sends the encapsulated packet directly to the test server at the other end.
[0093] No data copying is required; the only overhead is copying the sk_buff structure and encapsulating it with IPIP. The TCP packet load is also off the gateway, reducing the gateway's load and improving forwarding efficiency.
[0094] Specifically, the step of encapsulating the first data packet based on the tunnel identification information of the IP tunnel to obtain the second data packet may include the following steps: determining the packet header based on the tunnel identification information of the IP tunnel, whereby the tunnel identification information is used to identify the IP tunnel; and encapsulating the first data packet based on the packet header to generate the second data packet.
[0095] Specifically, the first data packet is encapsulated with the header structure corresponding to the IP tunnel to generate the second data packet. This allows data packets destined for one IP address to be encapsulated and forwarded to another IP address.
[0096] TCP / IP network data is transmitted in a streaming manner. A data stream consists of packets. To determine whether a received packet is a complete packet, the packet is processed during transmission; this is called packet encapsulation, which divides the packet into a header and a body. The header (i.e., the header structure) marks the beginning of the packet, and the size of the entire packet marks its end. The receiver simply unpacks the packet in the same way.
[0097] In summary, this embodiment of the invention uses an extended filter located at the injection point of the traffic controller to copy the initial traffic data sent by the source server, obtaining a first data packet. This bypasses the process of establishing a connection with the Transmission Control Protocol (TCP) and bypasses the kernel protocol stack. Therefore, copying the initial traffic data through the extended filter efficiently obtains the first data packet and reduces the gateway load. Then, the first data packet is forwarded to the test server via an Internet Protocol (IP) tunnel, allowing the test server to test preset services based on the test traffic data in the first data packet. This solves the current problems of high cost and low efficiency in copying and forwarding traffic data, reduces the gateway load, and thus improves the efficiency of copying and forwarding traffic data while saving costs.
[0098] The following is combined with Figure 3 The data testing method provided in the embodiments of the present invention will be described in detail.
[0099] Figure 3 This is a flowchart of a data testing method provided in an embodiment of the present invention;
[0100] like Figure 3 As shown, this data forwarding method may include steps 310-330, and is applied to a test server, as detailed below:
[0101] Step 310: Receive the second data packet sent by the gateway.
[0102] The gateway forwards the second data packet to the IPIP tunnel, and the other end of the IPIP tunnel, i.e., the test server, receives the second data packet.
[0103] Step 320: Parse the second data packet to obtain test traffic data.
[0104] After receiving the data, the test server will perform TCP unpacking. Incomplete packets will be discarded, while complete HTTP requests can be parsed to obtain HTTP packets, which are the test traffic data.
[0105] Step 330: Test the preset services based on the test traffic data.
[0106] Finally, various preset business tests can be completed based on the test traffic data.
[0107] In summary, the embodiments of the present invention obtain test traffic data by parsing the second data packet sent by the gateway, and test preset services based on the test traffic data. This enables credible testing based on test traffic data obtained from real online traffic data, resulting in stronger authenticity and thus improving service performance.
[0108] Based on the above Figure 2The data forwarding method shown in the present invention also provides a data forwarding device, such as... Figure 4 As shown, the data forwarding device 400 may include:
[0109] The receiving module 410 is used to receive the initial traffic data sent by the source server. The initial traffic data is the data collected by the source server from the user terminal.
[0110] The replication module 420 is used to call the extended filter to replicate the initial traffic data and obtain the first data packet. The extended filter is set at the injection point of the traffic controller, and the traffic controller is set on the gateway.
[0111] The forwarding module 430 is used to forward the first data packet to the test server through the Internet Protocol (IP) tunnel, so that the test server can test the preset service based on the test traffic data in the first data packet.
[0112] In one possible embodiment, the data forwarding device 400 may further include:
[0113] The encapsulation module is used to encapsulate the first data packet according to the tunnel identification information of the IP tunnel to obtain the second data packet.
[0114] Forwarding module 430 is specifically used to forward the second data packet to the test server through an IP tunnel.
[0115] In one possible embodiment, the copying module 420 is specifically used for:
[0116] Invoke the extended filter so that it determines the test traffic data from the initial traffic data according to the pre-set filtering rules;
[0117] Copy the test traffic data to obtain the first data packet.
[0118] In one possible embodiment, the copying module 420 is specifically used for:
[0119] Obtain a preset data structure, which includes: structure parameters and protocol header; wherein, the protocol header is used to store the protocol header information of each layer of the protocol for the transmission of the first data packet between the layers of the protocol.
[0120] Based on the structural parameters, test traffic data and protocol header information are stored to obtain the first data packet.
[0121] In one possible embodiment, the copying module 420 is specifically used for:
[0122] The filter function stored in the extended filter is invoked to execute the pre-set filter rules and determine the test traffic data from the initial traffic data.
[0123] In summary, in this embodiment of the invention, the initial traffic data sent by the source server is copied by calling the extended filter set at the injection point of the traffic controller to obtain the first data packet. Here, the process of establishing a connection with the Transmission Control Protocol is omitted, and the kernel protocol stack is bypassed. Therefore, copying the initial traffic data through the extended filter can efficiently obtain the first data packet and reduce the gateway load. Then, the first data packet is forwarded to the test server through the Internet Protocol (IP) tunnel, so that the test server can test the preset service based on the test traffic data in the first data packet. In this way, the problems of high cost and low efficiency in the current copying and forwarding of traffic data are solved, the gateway load is reduced, and thus the efficiency of copying and forwarding traffic data can be improved and costs saved.
[0124] Based on the above Figure 3 The data testing method shown in this embodiment of the invention also provides a data testing device, such as... Figure 5 As shown, the data testing device 500 may include:
[0125] The receiving module 510 is used to receive the second data packet sent by the gateway.
[0126] The parsing module 520 is used to parse the second data packet to obtain test traffic data.
[0127] Test module 530 is used to test preset services based on test traffic data.
[0128] In summary, in this embodiment of the invention, test traffic data is obtained by parsing the second data packet sent by the gateway, and preset services are tested based on the test traffic data. This allows for credible testing based on real online traffic data, resulting in greater authenticity and thus improving service performance.
[0129] This invention also provides an electronic device, such as... Figure 6 As shown, it includes a processor 601, a communication interface 602, a memory 603, and a communication bus 604, wherein the processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604.
[0130] Memory 603 is used to store computer programs;
[0131] When processor 601 executes a program stored in memory 603, it performs the following steps:
[0132] Receive initial traffic data sent by the source server. The initial traffic data is the data collected by the source server from the user terminal.
[0133] The extended filter is invoked to copy the initial traffic data, resulting in the first data packet. The extended filter is set at the injection point of the traffic controller, which is connected to the gateway network.
[0134] The first data packet is forwarded to the test server via an Internet Protocol (IP) tunnel, so that the test server can test the preset service based on the test traffic data in the first data packet.
[0135] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0136] The communication interface is used for communication between the aforementioned terminal and other devices.
[0137] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0138] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0139] In another embodiment of the present invention, a computer-readable storage medium is also provided, which stores instructions that, when executed on a computer, cause the computer to perform any of the data forwarding methods or data testing methods described in the above embodiments.
[0140] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the data forwarding methods or data testing methods described in the above embodiments.
[0141] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).
[0142] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0143] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0144] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. A data forwarding method, characterized by, The method applied to a gateway comprises: receiving initial traffic data sent by a source server, the initial traffic data being data collected by the source server from a user terminal; calling an extended filter to copy the initial traffic data to obtain a first data packet, the extended filter being arranged at an injection point of a traffic controller, the traffic controller being connected to the gateway in a network; forwarding the first data packet to a test server through an Internet Protocol (IP) tunnel, so that the test server tests a preset service based on test traffic data in the first data packet; the calling of the extended filter to copy the initial traffic data to obtain the first data packet comprises: calling the extended filter, so that the extended filter determines the test traffic data from the initial traffic data according to a filtering rule in a pre-set map mechanism; copying the test traffic data to obtain the first data packet, the first data packet being a TCP data packet; wherein the copying of the test traffic data to obtain the first data packet comprises: obtaining a preset data structure, the preset data structure being a socket buffer, the preset data structure comprising: a structure parameter and a protocol header; wherein the protocol header is used to store protocol header information of each layer protocol, for transmission of the first data packet between the each layer protocol; storing the test traffic data and the protocol header information based on the structure parameter to obtain the first data packet.
2. The method according to claim 1, before the forwarding of the first data packet to the test server through the Internet Protocol (IP) tunnel, the method further comprises: encapsulating the first data packet to obtain a second data packet according to tunnel identification information of the IP tunnel; the forwarding of the first data packet to the test server through the Internet Protocol (IP) tunnel comprises: forwarding the second data packet to the test server through the IP tunnel.
3. The method according to claim 1, the calling of the extended filter, so that the extended filter determines the test traffic data from the initial traffic data according to a pre-set filtering rule, comprises: calling a filtering function stored in the extended filter, so that the filtering function executes the pre-set filtering rule to determine the test traffic data from the initial traffic data.
4. A data forwarding apparatus characterized by comprising: The device applied to a gateway comprises: a receiving module configured to receive initial traffic data sent by a source server, the initial traffic data being data collected by the source server from a user terminal; a copying module configured to call an extended filter to copy the initial traffic data to obtain a first data packet, the extended filter being arranged at an injection point of a traffic controller, the traffic controller being arranged on the gateway; a forwarding module configured to forward the first data packet to a test server through an Internet Protocol (IP) tunnel, so that the test server tests a preset service based on test traffic data in the first data packet; wherein the copying module is specifically configured to: calling the extended filter, so that the extended filter determines the test traffic data from the initial traffic data according to a filtering rule in a preset map mechanism; copying the test traffic data to obtain the first data packet, the first data packet being a TCP data packet; The copying module is specifically further used for: obtaining a preset data structure, the preset data structure being a socket cache, the preset data structure comprising: a structure parameter and a protocol header; wherein the protocol header is used for storing protocol header information of each layer protocol, so as to be used for transmission of the first data packet between each layer protocol; storing the test traffic data and the protocol header information based on the structure parameter to obtain the first data packet.
5. The apparatus of claim 4, further comprising: a packaging module configured to package the first data packet according to tunnel identification information of the IP tunnel to obtain a second data packet; The forwarding module is specifically configured to forward the second data packet to the test server through the IP tunnel.
6. An electronic device, comprising: comprising: at least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-3.
7. A non-transitory computer-readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to enable the computer to perform the method of any one of claims 1-3.
8. A computer program product comprising a computer program which, when executed by a processor, implements the method of any one of claims 1-3.
Citation Information
Patent Citations
An application program testing method and device
CN109861875A
Data forwarding method and device and readable storage medium
CN111585896A
Data processing method and device, server and storage medium
CN112532714A