Virtual service packet capturing method and device of load balancing device
By enabling virtual service packet capture in the load balancer, the method of obtaining and matching virtual service sessions solves the problem of difficulty in obtaining packets in the virtual service process, and realizes the complete packet acquisition and functional detection of virtual services.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HANGZHOU DPTECH TECH
- Filing Date
- 2023-04-25
- Publication Date
- 2026-07-24
AI Technical Summary
In load balancing devices, existing technologies cannot effectively obtain complete messages in the virtual service process, making it impossible to perform functional testing, analysis, and problem localization.
By enabling the virtual service packet capture function of the load balancer, the driver side obtains packets and transfers them to the packet capture process. Based on the packet capture process, virtual service sessions are matched. When a target session is matched, the packets are stored in a preset location. The target packets are determined by using a five-tuple filter, and the packet capture process is completed in the distributed device through the service board CPU.
It enables the complete acquisition of virtual service packets from load balancers, supports functional detection, analysis, and problem solving, and is applicable to both single-box and distributed devices.
Smart Images

Figure CN116346649B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer information processing, and more specifically, to a method and apparatus for capturing virtual service packets in a load balancing device. Background Technology
[0002] Packet capture involves intercepting and storing data packets transmitted and received over a network. This data can be used for data analysis, problem localization, and functional testing. Currently, common packet capture methods typically involve capturing all packets from a physical port or targeting specific packets by specifying a five-tuple.
[0003] As the volume of business access to web applications continues to increase, resource servers will face more and more challenges. In the early stages of website development, server processing power can be improved from a single-machine perspective by increasing hardware processing power, such as CPU processing power and memory capacity. However, single machines have performance bottlenecks, and once these bottlenecks are reached, the cost of further improvement becomes extremely high. To meet the challenges of large-scale websites, such as massive user volume, high concurrency, and massive data, and to solve the resource shortage caused by high access volume and to utilize service resources rationally and efficiently, application load balancing technology can be used. This involves forming a cluster of multiple servers, using load balancing equipment to distribute user requests across multiple servers for processing, and then returning the corresponding data to the client. The service provided by the server is called the real service. The service provided to the client by the load balancer is called the virtual service.
[0004] Users need to use packet capture to analyze whether the cluster environment has been successfully built and is running normally. In a load-balanced network, the client knows that the IP it is accessing is the IP of the virtual service. After the client requests access to the virtual service, it references the real service group through the virtual service, and then references the real service through a scheduling algorithm to complete one access. The virtual service and the real service packets do not use the same physical interface, and packet capture based on the port can only obtain the packet for accessing the virtual service or the packet for referencing the real service in a single instance. Moreover, during the process from the virtual service to the real service, IP address translation occurs, and the five-tuple of the packet will change, making it impossible to capture packets based on a specified five-tuple.
[0005] Therefore, a new method and device for capturing virtual service packets in load balancing equipment is needed.
[0006] The information disclosed in the background section is only intended to enhance the understanding of the background of this application, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0007] In view of this, this application provides a method and apparatus for capturing virtual service packets in a load balancing device, which can obtain complete packets in the virtual service process, and then perform functional testing, problem analysis, problem location and problem solving on the virtual service-related functions of the load balancing device.
[0008] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.
[0009] According to one aspect of this application, a method for capturing virtual service packets in a load balancer is proposed. The method includes: enabling the virtual service packet capture function of the load balancer; obtaining packets from the driver side of the load balancer; transferring the packets to a packet capture process; matching the virtual service session corresponding to the packets in the load balancer based on the packet capture process; and storing the packets in a preset location when a virtual service session is matched and is the target session.
[0010] In one exemplary embodiment of this application, the method further includes: when a virtual service session is not matched, determining whether the message is a target message by means of a five-tuple filtering method; when the message is a target message, storing the message in a preset location.
[0011] In one exemplary embodiment of this application, after enabling the virtual service packet capture function of the load balancer, the method further includes: traversing the existing sessions of the load balancer; determining the target session; and setting a packet capture session flag for the target session.
[0012] In one exemplary embodiment of this application, determining the target session includes: obtaining the source IP and destination IP of the current packet capture; and using the source IP corresponding to the client and the destination IP corresponding to the virtual service as the target session.
[0013] In one exemplary embodiment of this application, setting a packet capture session tag for the target session includes: setting a packet capture session tag for the target session based on the source IP and destination IP of the locally captured packets.
[0014] In one exemplary embodiment of this application, transferring the message to the packet capture process further includes: sending the message through the original business process.
[0015] In one exemplary embodiment of this application, matching a virtual service session corresponding to the packet in the load balancer based on the packet capture process includes: obtaining the source IP and destination IP of the packet based on the packet capture process; and matching a virtual service session corresponding to the packet in the load balancer based on the source IP and destination IP.
[0016] In one exemplary embodiment of this application, storing the message in a preset location includes: determining the number of currently captured messages; and storing the message in a captured message linked list when the number is less than a number threshold.
[0017] In one exemplary embodiment of this application, storing the message in a preset location when the message is a target message includes: establishing a target session based on the source IP and destination IP of the target message when the message is a target message.
[0018] According to one aspect of this application, a virtual service packet capture device for a load balancer is proposed. The device includes: an activation module for activating the virtual service packet capture function of the load balancer; an acquisition module for acquiring packets from the driver side of the load balancer; a transfer module for transferring the packets to the packet capture process; a matching module for matching the virtual service session corresponding to the packets in the load balancer based on the packet capture process; and a storage module for storing the packets in a preset location when a virtual service session is matched and is the target session.
[0019] According to one aspect of this application, an electronic device is provided, comprising: one or more processors; a storage device for storing one or more programs; and, when the one or more programs are executed by the one or more processors, causing the one or more processors to implement the method as described above.
[0020] According to one aspect of this application, a computer-readable medium is provided having a computer program stored thereon that, when executed by a processor, implements the method described above.
[0021] According to the virtual service packet capture method and apparatus for load balancing devices of this application, by enabling the virtual service packet capture function of the load balancing device; obtaining packets from the driver side of the load balancing device; transferring the packets to the packet capture process; matching the virtual service session corresponding to the packets in the load balancing device based on the packet capture process; and storing the packets in a preset location when a virtual service session is matched and is the target session, the complete packets in the virtual service process can be obtained, thereby enabling functional testing, problem analysis, problem location, and problem solving of the virtual service-related functions of the load balancing device.
[0022] It should be understood that the above general description and the following detailed description are merely exemplary and do not limit this application. Attached Figure Description
[0023] The above and other objects, features, and advantages of this application will become more apparent from the detailed description of exemplary embodiments with reference to the accompanying drawings. The drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.
[0024] Figure 1 This is a schematic diagram of existing packet capture methods.
[0025] Figure 2 This is a flowchart illustrating a virtual service packet capture method for a load balancing device according to an exemplary embodiment.
[0026] Figure 3 This is a flowchart illustrating a virtual service packet capture method for a load balancing device according to another exemplary embodiment.
[0027] Figure 4 This is a flowchart illustrating a virtual service packet capture method for a load balancing device according to another exemplary embodiment.
[0028] Figure 5 This is a block diagram illustrating a virtual service packet capture device for a load balancing device according to an exemplary embodiment.
[0029] Figure 6 This is a block diagram illustrating an electronic device according to an exemplary embodiment.
[0030] Figure 7 This is a block diagram illustrating a computer-readable medium according to an exemplary embodiment. Detailed Implementation
[0031] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, they are provided so that this application will be thorough and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted.
[0032] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.
[0033] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0034] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0035] It should be understood that although the terms first, second, third, etc., may be used herein to describe various components, these components should not be limited by these terms. These terms are used to distinguish one component from another. Therefore, the first component discussed below may be referred to as the second component without departing from the teachings of this application. As used herein, the term "and / or" includes all combinations of any one and more of the associated listed items.
[0036] Those skilled in the art will understand that the accompanying drawings are merely schematic diagrams of exemplary embodiments, and the modules or processes in the drawings are not necessarily essential for implementing this application, and therefore cannot be used to limit the scope of protection of this application.
[0037] The technical abbreviations used in this application are explained as follows:
[0038] Packet capture involves intercepting and storing data packets transmitted and received over a network. This data can be used for data analysis, problem localization, and functional testing. Currently, common packet capture methods include capturing all packets from a physical port or targeting specific packets using a specified 5-tuple.
[0039] Five-tuple: A five-tuple is a communications term. It typically refers to the source IP address, source port, destination IP address, destination port, and transport layer protocol.
[0040] Real services: Individuals that provide service resources to users, uniquely identified by their IP address and port. Multiple real services can reside on one or more physical servers. When a device sends a user request to a real service, it will modify the destination IP address and destination port to match the IP address and port of the real service.
[0041] Real service group: A collection of multiple real services. Virtual services can determine the scope of real services to be scheduled and the scheduling algorithm to be used by referencing the real service group.
[0042] Virtual service: The services provided by the load balancing device are called virtual services. When a user's access request arrives at the device, it will be matched with a virtual service based on the IP address, port and protocol, and then dispatched to a real service by the scheduling algorithm of the associated real service group.
[0043] Scheduling Algorithm: After a user accesses a virtual service, the real service group allocates the request to a real service according to the scheduling algorithm. Application load balancing scheduling algorithms support round-robin, weighted round-robin, minimum traffic, weighted least connections, and source address hashing. For example, when a virtual service receives multiple user requests, the requests are sequentially allocated to different real services according to the round-robin algorithm.
[0044] Application cluster: The same application is deployed on multiple machines to form a processing cluster, which receives requests distributed by the load balancer, processes them, and returns the corresponding data.
[0045] Load balancing: Distributing user access requests to nodes in a cluster using a certain algorithm.
[0046] The applicant, through research on existing technologies, discovered that packet capture can be broadly categorized into two types based on the capture location: switch chip packet capture and CPU packet capture. For load balancing equipment, the packet capture method is CPU packet capture, which involves capturing and saving packets sent to the CPU. Currently, packet capture is interface-based, and can only capture packets from a single physical port at a time. If filtering is required for packets from a single interface, it can only target a fixed five-tuple. Specific implementation methods are as follows... Figure 1 As shown:
[0047] 1. Enable packet capture on the device, set a packet capture timer, and register packet capture in the driver.
[0048] 2. After the driver registers and captures packets, it sends a copy of the CPU packet to the packet capture interface.
[0049] 3. After receiving packets, the packet capture interface filters the packets according to the filtering conditions and stores them in the kernel linked list.
[0050] 4. The user selects a file to download and receives a message.
[0051] In a load-balanced environment, when an internet user accesses a virtual service address for a resource, because the virtual service is associated with a real service group, the user request is sent to the designated real service to obtain the service resource based on the application load balancing session persistence and scheduling algorithm. For example, when multiple users access the virtual service address simultaneously, the user requests will be distributed to ServerA and ServerB according to the scheduling algorithm. During this process, after the request arrives at the application load balancing device, it undergoes destination address translation and source address translation, and the five-tuple of the packet may change.
[0052] In this environment, it's impossible to consistently capture packets from the virtual service to the real service. Client-to-virtual service packets typically occur concurrently during functional testing. If you want to analyze traffic through packet capture, you can only do so by unconditionally capturing packets from the inbound interfaces and then manually analyzing the captured packets. Manually analyzing the necessary packets from a large volume of data significantly hinders testing progress and functional analysis.
[0053] Under normal application load conditions, packet capture can only be performed on the inbound interface of user requests. The captured packets represent user requests being transmitted over the network to the load balancer; the obtained packets are only those from the client to the virtual service. The destination of the load balancing packets after IP translation is unknown, and the connection established between the virtual service and the real service cannot be traced through packet capture. When testing application load balancing functionality, it is impossible to determine whether the application load is normal by focusing on a specific packet traffic.
[0054] In view of the technical deficiencies in the prior art, this application proposes a method for capturing virtual service packets in a load balancing device. Based on the technology in this application, an entire access traffic stream under a load balancing service can be traced. The content of this application will be described in detail below with the aid of specific embodiments.
[0055] Figure 2 This is a flowchart illustrating a virtual service packet capture method for a load balancing device according to an exemplary embodiment. The virtual service packet capture method 20 of the load balancing device includes at least steps S202 to S212.
[0056] like Figure 2 As shown in Figure S202, enable the virtual service packet capture function of the load balancer. Users can enable the virtual service packet capture function in the settings on the main page.
[0057] In S204, the packets are acquired by the driver side of the load balancer. First, the packet capture function is registered on the driver side.
[0058] Normally, after a packet arrives at the device, it first passes through the driver to determine whether to use a slow or fast forwarding process. Only packets requiring slow forwarding are sent to the CPU for processing. In this case, fast forwarding packets are not sent to the CPU and therefore cannot be captured. In this application, to avoid the situation where fast forwarding packets cannot be captured, packet capture is first registered in the driver. After registration, the driver copies all packets into the packet capture process set in this application before the forwarding process.
[0059] In S206, the message is transferred to the packet capture process. The message is sent through the original business process. After the user enables the packet capture function, a dedicated packet capture process can be established to handle subsequent steps.
[0060] In step S208, the virtual service session corresponding to the packet is matched in the load balancer based on the packet capture process. The source IP and destination IP of the packet are obtained based on the packet capture process; the virtual service session corresponding to the packet is matched in the load balancer based on the source IP and destination IP.
[0061] More specifically, each traffic of a virtual service is recorded in the form of a session. Therefore, the core of virtual service packet capture is to find the accurate destination session. You only need to save the traffic of that session to complete the packet capture.
[0062] In S210, when a virtual service session is matched and is the target session, the message is stored in a preset location. The number of currently captured messages is determined; if the number is less than a threshold, the message is stored in the captured message list.
[0063] In one specific embodiment, when saving a packet, the number of packets currently captured is first determined. If the number of packets is less than the set packet capture threshold, the current packet is copied to the linked list of captured packets. Simultaneously, the number of captured packets is incremented by 1. After saving the packet, the number of captured packets is checked again. If the number of packets is greater than or equal to the set packet capture threshold, packet capture stops.
[0064] In one embodiment, packet capture can also be stopped by setting packet capture conditions at the start or manually. When stopping packet capture, the driver uploading message switch is turned off, the session flag is stopped, and the packet capture timer is turned off.
[0065] In S212, if no virtual service session is matched, the packet is determined to be a target packet by filtering with a five-tuple; if the packet is a target packet, a target session is established based on the source IP and destination IP of the target packet, and the packet is stored in a preset location.
[0066] As configured above, a packet capture service is registered on the driver side, which means that all packets received by the load balancer are sent to the packet capture processing flow.
[0067] For all messages acquired by the driver, there are two scenarios. If the message belongs to a known session, the driver checks whether the session it belongs to is the target session. If it is the target session, the message is directly uploaded and stored in the captured message list.
[0068] If a packet does not belong to a known session, it is considered the first packet. Before a session is established, the first packet is filtered using a five-tuple method to determine whether it should be captured. The first packet matching the source and destination IPs is the first packet of a newly established target session and will be sent to be stored in the captured packet list.
[0069] In one embodiment, after packet capture begins, a packet capture timer can be started. The packet capture timer is related to the packet capture time in the packet capture conditions. The maximum number of packets to capture is set, the number of captured packets is set to 0, and packet capture stops when the number of packets captured reaches the set threshold.
[0070] According to the virtual service packet capture method of the load balancing device in this application, by enabling the virtual service packet capture function of the load balancing device; obtaining packets from the driver side of the load balancing device; transferring the packets to the packet capture process; matching the virtual service session corresponding to the packets in the load balancing device based on the packet capture process; and storing the packets in a preset location when a virtual service session is matched and is the target session, the complete packets in the virtual service process can be obtained, thereby enabling functional testing, problem analysis, problem location, and problem solving of the virtual service-related functions of the load balancing device.
[0071] It should be clearly understood that this application describes how specific examples are formed and used, but the principles of this application are not limited to any details of these examples. Rather, based on the teachings of the disclosure of this application, these principles can be applied to many other embodiments.
[0072] Figure 3 This is a flowchart illustrating a virtual service packet capture method for a load balancing device according to another exemplary embodiment. Figure 3 The process shown in step 30 is... Figure 2 Supplementary description of the process shown.
[0073] like Figure 3 As shown in S302, enable the virtual service packet capture function of the load balancer.
[0074] In S304, the existing sessions of the load balancer are traversed.
[0075] In S306, the target session is defined. Users can set the target of this packet capture when the packet capture service is started, which can be specifically the source IP and destination IP of this packet capture.
[0076] The packet capture process can obtain the source IP and destination IP of this packet capture; the source IP corresponding to the client and the destination IP corresponding to the virtual service are used as the target session.
[0077] In S308, a packet capture session flag is set for the target session. The packet capture session flag can be set based on the source IP and destination IP of the locally captured packets.
[0078] After enabling virtual service packet capture, it will first iterate through all existing sessions of the load balancer and then find the corresponding virtual service session by using the source IP and destination IP set by the user for this packet capture.
[0079] The source IP corresponds to the client, and the destination IP corresponds to the virtual service IP. Once found, the session is marked as the target session and tagged with the session tag for this packet capture.
[0080] More specifically, you can set tags based on the source IP and destination IP information of this packet capture, and you can also include, for example, the current timestamp. Each new virtual service packet capture task will generate a different tag than before to avoid confusion with other sessions.
[0081] If no corresponding session is found, no processing is performed in this step. Newly created sessions will also be checked during the packet capture time to prevent newly created target sessions from being ignored.
[0082] In the virtual service packet capture method of the load balancing device in this application, each traffic of the load balancing device is recorded in the form of a session. Therefore, the session is the focus of this solution. The target session is marked to indicate that all packets of this session need to be captured and saved.
[0083] Figure 4 This is a flowchart illustrating a virtual service packet capture method for a load balancing device according to another exemplary embodiment. Figure 4 The process shown in step 40 is... Figure 2 A detailed description of the process shown.
[0084] like Figure 4 As shown, in S402, the device receives a message.
[0085] In S404, the driver side acquires messages.
[0086] In S406, is packet capture service enabled?
[0087] In S408, normal business processes are handled.
[0088] In S410, the message is copied into the packet capture process, and the original message is processed according to the normal business process.
[0089] In S412, query whether the message belongs to the currently existing session.
[0090] In S414, is this session the target session?
[0091] In S416, it is copied to the CPU.
[0092] In S418, packet loss occurs.
[0093] In S420, the first packet is sent.
[0094] In S422, it is copied to the CPU.
[0095] Does S424 satisfy the quintuple condition?
[0096] In S426, the message is saved.
[0097] It's worth mentioning that the packet capture process described above can be configured for a single box-type device, and this process can capture packets corresponding to virtual services. For distributed devices, session packets are processed directly on the service board and forwarded without being processed by the main control CPU. According to the solution in this application, additional settings can be made for the packet capture scheme of distributed devices.
[0098] In one embodiment, packet capture by the distributed device can first be performed by the service board CPU to complete the capture and filtering process, and then the packets that meet the requirements can be sent to the main control CPU for storage. The more specific process is as follows:
[0099] 1. After the distributed device starts packet capture, the main control CPU notifies the CPU of the service board that it needs to capture virtual service packets. The main control CPU opens the packet receiving channel and can receive and save the packets with packet capture tags sent by the CPU of the service board.
[0100] 2. After receiving the notification from the main controller, the CPU on the service board starts capturing packets for virtual services. The specific process is similar to that of the box-type device.
[0101] 3. Virtual service messages captured by the business board will be marked with packet capture tags and then sent to the main control CPU through the interaction channel of the distributed device.
[0102] 4. The main control CPU's packet receiving module has a packet capture entry point detection function. Packets with packet capture markers will be saved in the captured packet linked list.
[0103] This application presents a method for capturing virtual service packets on a load balancer, enabling the load balancer to capture packets for virtual services. It accurately captures the entire session flow of a request sent by a unique client to access the real service through the load balancer by using the source and destination IPs. The proposed distributed device solution also allows chassis-based devices to perform packet capture for virtual services.
[0104] The virtual service packet capture method for load balancing devices in this application hinges on identifying the desired session and acquiring its packets. In this application, if the desired session has already been established when packet capture begins, all sessions are traversed simultaneously, and the desired session is marked. Subsequent packets from this session are then directly saved. If the desired session has not been established when packet capture begins, the first packet will necessarily meet the IP capture requirements. In this case, the first packet of the session is filtered using a five-tuple packet capture method. Simultaneously, newly created sessions are checked to see if they are the desired session; if so, they are marked, and subsequent packets are also captured and saved.
[0105] The virtual service packet capture method for load balancing devices in this application provides a virtual service packet capture solution for distributed devices. By completing the main packet capture process on the business board CPU, it avoids the business packets not being sent to the main control CPU, thus preventing the main control CPU from capturing packets.
[0106] The virtual service packet capture method for load balancing devices in this application can also provide a page switch to distinguish between virtual service packet capture and normal packet capture. Users can configure the two functions of normal packet capture and virtual service packet capture on the page to meet the needs of different application scenarios.
[0107] Those skilled in the art will understand that all or part of the steps of the above embodiments are implemented as a computer program executed by a CPU. When the computer program is executed by the CPU, it performs the functions defined by the method provided in this application. The program can be stored in a computer-readable storage medium, such as a read-only memory, a magnetic disk, or an optical disk.
[0108] Furthermore, it should be noted that the above figures are merely illustrative representations of the processes included in the method according to exemplary embodiments of this application, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.
[0109] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0110] Figure 5 This is a block diagram illustrating a virtual service packet capture device for a load balancing equipment according to an exemplary embodiment. Figure 5 As shown, the virtual service packet capture device 50 of the load balancing equipment includes: an opening module 502, an acquisition module 504, a transfer module 506, a matching module 508, and a storage module 510.
[0111] Enabling module 502 is used to enable the virtual service packet capture function of the load balancer;
[0112] The acquisition module 504 is used to acquire messages from the driver side of the load balancing device;
[0113] The transfer module 506 is used to transfer the message to the packet capture process;
[0114] The matching module 508 is used to match the virtual service session corresponding to the packet in the load balancer based on the packet capture process; the matching module 508 is also used to obtain the source IP and destination IP of the packet based on the packet capture process; and match the virtual service session corresponding to the packet in the load balancer based on the source IP and destination IP.
[0115] The storage module 510 is used to store the packet in a preset location when a virtual service session is matched and it is the target session. The storage module 510 is also used to determine whether the packet is a target packet by using a five-tuple filtering method when no virtual service session is matched; if the packet is a target packet, it stores the packet in the preset location. The storage module 510 is also used to determine the number of packets currently captured; if the number is less than a threshold, it stores the packet in the captured packet linked list.
[0116] According to the virtual service packet capture device of the load balancing device in this application, by enabling the virtual service packet capture function of the load balancing device; obtaining packets from the driver side of the load balancing device; transferring the packets to the packet capture process; matching the virtual service session corresponding to the packets in the load balancing device based on the packet capture process; and storing the packets in a preset location when a virtual service session is matched and is the target session, the complete packets in the virtual service process can be obtained, thereby enabling functional testing, problem analysis, problem location, and problem solving of the virtual service-related functions of the load balancing device.
[0117] Figure 6 This is a block diagram illustrating an electronic device according to an exemplary embodiment.
[0118] The following reference Figure 6 To describe an electronic device 600 according to this embodiment of the present application. Figure 6 The electronic device 600 shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0119] like Figure 6 As shown, the electronic device 600 is presented in the form of a general-purpose computing device. The components of the electronic device 600 may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, a bus 630 connecting different system components (including storage unit 620 and processing unit 610), a display unit 640, etc.
[0120] The storage unit stores program code that can be executed by the processing unit 610, causing the processing unit 610 to perform the steps described in this specification according to various exemplary embodiments of this application. For example, the processing unit 610 can perform actions such as... Figure 2 , Figure 3 , Figure 4 The steps are shown in the figure.
[0121] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache storage unit 6202, and may further include a read-only memory unit (ROM) 6203.
[0122] The storage unit 620 may also include a program / utility 6204 having a set (at least one) program module 6205, such program module 6205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0123] Bus 630 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the various bus structures.
[0124] Electronic device 600 can also communicate with one or more external devices 600' (e.g., keyboard, pointing device, Bluetooth device, etc.), enabling users to communicate with devices that interact with electronic device 600, and / or any device that allows electronic device 600 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 650. Furthermore, electronic device 600 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 660. Network adapter 660 can communicate with other modules of electronic device 600 via bus 630. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0125] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software, or by combining software with necessary hardware. Therefore, as... Figure 7As shown, the technical solution according to the embodiments of this application can be embodied in the form of a software product. The software product can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, mobile hard drive, etc.) or on a network, and includes several instructions to cause a computing device (such as a personal computer, server, or network device, etc.) to execute the above-described method according to the embodiments of this application.
[0126] In general, the virtual service packet capture method and apparatus for load balancing devices disclosed herein, after starting packet capture, starts a packet capture timer, which is related to the packet capture time in the packet capture conditions; a maximum number of packets to capture is set, and the number of captured packets is set to 0; packet capture stops when the number of captured packets reaches the set threshold. After starting virtual service packet capture, the device first registers packet capture on the driver side. The reason for registering packet capture on the driver is that after packets arrive at the device, they will first pass through the driver to determine whether to follow a slow or fast forwarding process; only slow forwarding packets will be processed by the CPU. To avoid missing fast forwarding packets, after registering packet capture, the driver will copy all packets to the packet capture process before the forwarding process. Each traffic of the virtual service is recorded in the form of a session; therefore, virtual service packet capture focuses on finding the accurate destination session, and only needs to save the traffic of that session to complete the packet capture. After starting virtual service packet capture, all existing sessions of the load balancer are traversed first, and the corresponding virtual service session is found by using the source IP and destination IP of the captured packets. The source IP corresponds to the client, and the destination IP corresponds to the virtual service IP. Once found, the session is marked as the target session and tagged with the session flag for this packet capture. The session flag is related to the source and destination IPs of this packet capture. Each new virtual service packet capture will generate a different flag than before to avoid confusion with other sessions. If no corresponding session is found, no processing is performed at this step. Newly created sessions will also be checked during the packet capture time to prevent newly created target sessions from being ignored. After receiving the packets sent by the driver, the virtual service packet capture will first check the session. Since all packets have been sent, there are two possibilities. If the packet belongs to a known session, it will check whether the session it belongs to is the target session. If it is the target session, the packet will be sent directly and hopefully saved in the captured packet list. If the packet does not belong to a known session, it is the first packet. Before a session is established, the first packet will be filtered using a five-tuple method to determine whether it is a packet that needs to be captured. The first packet that matches the source and destination IPs of the packet capture is the first packet of the newly created target session and will be sent and hopefully saved in the captured packet list. When saving packets, first check the number of packets already captured. If the number of packets is less than the set capture count, copy the current packet to the captured packet list. Simultaneously, increment the number of captured packets by 1. After saving the packets, check the number of captured packets again. When the number of packets is greater than or equal to the set capture count, stop packet capture. Packet capture can be stopped using the capture conditions set at the beginning or manually. When stopping packet capture, disable the driver's packet upload switch, stop session marking, and disable the packet capture timer. For a single box-type device, this process can capture packets corresponding to virtual services. For distributed devices, session packets are processed directly on the service board and forwarded without reaching the main control CPU. A packet capture scheme for distributed devices needs to be designed. Distributed device packet capture uses the service board CPU to complete the capture and filtering process, and then uploads the qualified packets to the main control CPU for storage. After the distributed device starts packet capture, the main control CPU notifies the service board CPU that virtual service packets need to be captured.The main control CPU opens a message receiving channel, allowing it to receive and save messages with capture tags sent by the service board CPU. Upon receiving notification from the main control CPU, the service board CPU initiates virtual service packet capture, following a process similar to that of the box-type device. The virtual service messages captured by the service board are tagged with capture tags and then sent to the main control CPU via the distributed device's interaction channel. The main control CPU's packet receiving module has a capture entry point detection mechanism; messages with capture tags are saved in the captured message linked list.
[0127] The software product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections with one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0128] The computer-readable storage medium may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, capable of transmitting, propagating, or transmitting programs for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0129] Program code for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0130] The aforementioned computer-readable medium carries one or more programs. When these programs are executed by a device, the computer-readable medium performs the following functions: enabling the virtual service packet capture function of the load balancer; acquiring packets from the driver side of the load balancer; transferring the packets to the packet capture process; matching the virtual service session corresponding to the packet in the load balancer based on the packet capture process; storing the packet in a preset location when a virtual service session is matched and is the target session; determining whether the packet is the target packet by using a five-tuple filtering method when no virtual service session is matched; and storing the packet in a preset location when the packet is the target packet. The computer-readable medium may also perform the following functions: traversing the existing sessions of the load balancer; determining the target session; and setting a packet capture session flag for the target session.
[0131] Those skilled in the art will understand that the above modules can be distributed in the device as described in the embodiments, or they can be modified accordingly and placed in one or more devices that are unique to this embodiment. The modules in the above embodiments can be combined into one module, or they can be further divided into multiple sub-modules.
[0132] Through the description of the above embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, mobile terminal, or network device, etc.) to execute the methods according to the embodiments of this application.
[0133] Exemplary embodiments of this application have been specifically shown and described above. It should be understood that this application is not limited to the detailed structures, arrangements, or implementation methods described herein; rather, this application is intended to cover various modifications and equivalent arrangements contained within the spirit and scope of the appended claims.
Claims
1. A method for capturing virtual service packets in a load balancing device, characterized in that, include: Enable the virtual service packet capture function of the load balancer; The message is obtained from the driver side of the load balancing device; The message is then transferred to the packet capture process; Based on the packet capture process, the virtual service session corresponding to the packet is matched in the load balancer; When a virtual service session is matched and is the target session, the message is stored in a preset location; When no virtual service session is matched, the packet is determined to be the target packet by using a five-tuple filtering method. When the message is a target message, the message is stored in a preset location.
2. The method as described in claim 1, characterized in that, After enabling the virtual service packet capture function of the load balancer, it also includes: Iterate through the existing sessions of the load balancer; Identify the target session; Set a packet capture session flag for the target session.
3. The method as described in claim 2, characterized in that, Determine the target session, including: Obtain the source IP and destination IP of this packet capture; The source IP corresponding to the client and the destination IP corresponding to the virtual service are used as the target session.
4. The method as described in claim 2, characterized in that, Setting a packet capture session flag for the target session includes: Set the packet capture session tag for the target session based on the source IP and destination IP of the local packet capture.
5. The method as described in claim 1, characterized in that, The process of transferring the message to the packet capture process also includes: The message was sent through the existing business process.
6. The method as described in claim 1, characterized in that, Based on the packet capture process, the virtual service session corresponding to the packet is matched in the load balancer, including: The source IP and destination IP of the packet are obtained based on the packet capture process described above; Based on the source IP and destination IP, the load balancer matches the virtual service session corresponding to the packet.
7. The method as described in claim 1, characterized in that, Storing the message in a preset location includes: Determine the number of packets that have been captured. When the number is less than the number threshold, the message is stored in the captured message linked list.
8. The method as described in claim 1, characterized in that, When the message is a target message, storing the message in a preset location includes: When the message is a target message, a target session is established based on the source IP and destination IP of the target message.
9. A virtual service packet capture device for a load balancing equipment, characterized in that, include: The enable module is used to enable the virtual service packet capture function of the load balancer. The acquisition module is used to acquire messages from the driver side of the load balancing device; The transfer module is used to transfer the message to the packet capture process; The matching module is used to match the virtual service session corresponding to the packet in the load balancer based on the packet capture process. The storage module is used to store the packet in a preset location when a virtual service session is matched and it is the target session, and to determine whether the packet is the target packet by a five-tuple filtering method when no virtual service session is matched, and to store the packet in the preset location when the packet is the target packet.