A network packet processing method, apparatus, device, medium and program product

By using host devices with different listening modes in the Tengine cluster and dynamically adjusting the LocalIP address, the overload problem during peak traffic periods is solved, the fault tolerance and reliability of the cluster are improved, and more efficient traffic distribution and service continuity are achieved.

CN121056540BActive Publication Date: 2026-07-24BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
Filing Date
2025-08-22
Publication Date
2026-07-24

AI Technical Summary

Technical Problem

The bandwidth limitations of the local Internet Protocol address of hosts in the Tengine cluster can easily cause overload during periods of high traffic, affecting the cluster's processing capacity and reliability.

Method used

By operating the host devices in the Tengine cluster in different listening modes, the first host device can listen to multiple LocalIP addresses, the second host device can listen to one LocalIP address, and the listening mode can be dynamically adjusted according to a preset algorithm to achieve flexible traffic distribution and load balancing.

Benefits of technology

It alleviated the host overload problem during periods of high traffic, improved the fault tolerance and reliability of the cluster, and ensured the cluster's processing capacity and service continuity in complex network environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121056540B_ABST
    Figure CN121056540B_ABST
Patent Text Reader

Abstract

The present disclosure relates to the technical field of computers, and particularly relates to a network message processing method and device, equipment, medium and program product. The method comprises: a first host device and a second host device in a Tengine cluster work in different listening modes. Since the first host device works in a first listening mode supporting listening to multiple LocalIP addresses, the cloud gateway XGW can forward messages to the first host device through multiple LocalIP addresses. This scheme can distribute more messages to the first host device working in the first listening mode, thereby alleviating the situation that the host is easy to overload during the high-traffic period. Moreover, in this scenario, even if the listening mode of other host devices fails, the overall processing capacity of the cluster can still be guaranteed, and the fault tolerance and reliability of the cluster are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a method, apparatus, device, medium, and program product for processing network messages. Background Technology

[0002] In the current network architecture, the Tengine cluster serves as a key load balancing component, responsible for receiving and distributing network traffic from the Layer 4 gateway.

[0003] For each host in the Tengine cluster, the cloud gateway XGW forwards traffic to the host using a unique local Internet Protocol address pre-configured for that host. Each host in the Tengine cluster distributes network traffic by listening to this pre-configured unique local Internet Protocol address.

[0004] Due to the bandwidth limitations of local Internet Protocol (IP) addresses, each host can only receive a limited amount of traffic. During periods of high traffic, this can easily lead to traffic overload. Furthermore, if the listening methods of some hosts fail, it can affect the overall processing capacity of the Tengine cluster, thereby reducing its reliability. Summary of the Invention

[0005] To address the aforementioned technical problems, this disclosure provides a method, apparatus, device, medium, and program product for processing network packets.

[0006] Firstly, this disclosure provides a method for processing network packets. The method is applied to a cloud gateway XGW, which is equipped with a Tengine cluster. The Tengine cluster includes at least a first host device and a second host device. The method includes:

[0007] The system receives a first message; according to a preset algorithm, it determines a first LocalIP address from the LocalIP addresses corresponding to the first host device and the second host device respectively, and encapsulates the first LocalIP address in the first message to obtain a second message; when the first LocalIP address is one of the multiple LocalIP addresses corresponding to the first host device, it forwards the second message to the first host device; or, when the first LocalIP address is the unique LocalIP address corresponding to the second host device, it forwards the second message to the second host device; wherein, the first host device operates in a first listening mode, which supports listening to multiple LocalIP addresses; the second host device operates in a second listening mode, which supports listening to one LocalIP address.

[0008] In some alternative implementations, after receiving the first message, the method further includes:

[0009] Receive the third message; when the total number of messages received by the first host device exceeds the first preset threshold, and the first host device switches from the first listening mode to the second listening mode, determine the second LocalIP address from the LocalIP addresses corresponding to the first host device and the second host device respectively, and encapsulate the second LocalIP address in the third message to obtain the fourth message; when the second LocalIP address is the unique LocalIP address corresponding to the first host device, forward the fourth message to the first host device.

[0010] In some alternative implementations, the method further includes:

[0011] Receive the fifth message; when the packet traffic carrying the second LocalIP received by the first host device exceeds the second preset threshold, and the first host device switches from the second listening mode back to the first listening mode, determine the third LocalIP address from the LocalIP addresses corresponding to the first host device and the second host device respectively, and encapsulate the third LocalIP address in the fifth message to obtain the sixth message; when the third LocalIP address is one of the multiple LocalIP addresses corresponding to the first host device, forward the sixth message to the first host device.

[0012] In some alternative implementations, the method further includes, before receiving the first message:

[0013] When the target switch of the first host device is set to the on state, the first host device operates in the first monitoring mode; when the target switch of the second host device is set to the off state, the second host device operates in the second monitoring mode; wherein, the target switch is used to enable the first monitoring mode or the second monitoring mode.

[0014] In some optional implementations, the first host device is bound to a listener, and the number of listeners bound to the first host device is the same as the number of LocalIP addresses corresponding to the first host device; for each listener, the fourth LocalIP address bound to the listener and the port corresponding to the fourth LocalIP address are determined based on the index field pre-configured by the listener and the local network address range pre-configured by the first host device; wherein, the fourth LocalIP address is one of the multiple LocalIP addresses corresponding to the first host device.

[0015] In some alternative implementations, network address ranges are described using CIDR notation;

[0016] The fourth LocalIP address bound to the listener and the port corresponding to the fourth LocalIP address are determined based on the index field pre-configured by the listener and the local network address range pre-configured by the first host device. Specifically, the fourth LocalIP address and port are determined from the available IP addresses based on the index field; the available IP addresses are obtained from the network object, which is obtained by converting the local network address range using the IPNetwork module in the netaddr toolkit.

[0017] Secondly, this disclosure provides a network packet processing apparatus, the apparatus comprising:

[0018] A first receiving module is used to receive a first message; a first determining module is used to determine a first LocalIP address from the local Internet Protocol (IP) addresses corresponding to the first host device and the second host device respectively according to a preset algorithm, and encapsulate the first LocalIP address in the first message to obtain a second message; a first forwarding module is used to forward the second message to the first host device when the first LocalIP address is one of multiple LocalIP addresses corresponding to the first host device; or, a second forwarding module is used to forward the second message to the second host device when the first LocalIP address is the unique LocalIP address corresponding to the second host device; wherein, the first host device operates in a first listening mode, which supports listening to multiple LocalIP addresses; the second host device operates in a second listening mode, which supports listening to one LocalIP address.

[0019] Thirdly, this disclosure provides a computer device, including:

[0020] The memory and the processor are interconnected and communicate with each other. The memory stores computer instructions, and the processor executes the computer instructions to perform the method corresponding to the first aspect and any of its embodiments.

[0021] Fourthly, this disclosure provides a computer-readable storage medium storing computer instructions for causing a computer to perform the method corresponding to the first aspect and any embodiment thereof.

[0022] Fifthly, this disclosure provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method corresponding to the first aspect and any of its embodiments.

[0023] The technical solution provided in this disclosure has the following advantages compared with the prior art:

[0024] The network packet processing method disclosed herein operates the first and second host devices in the Tengine cluster under different listening modes. Since the first host device in the Tengine cluster operates in a first listening mode that supports listening to multiple LocalIP addresses, the cloud gateway XGW can forward packets to the first host device through multiple LocalIP addresses. Compared to the current cloud gateway XGW, which can only forward packets to the first host device through a single LocalIP address, the solution provided herein can distribute more packets to the first host device operating in the first listening mode, thereby alleviating the risk of host overload during periods of high traffic. Furthermore, in this scenario, even if the listening methods of other host devices fail, the overall processing capacity of the cluster can still be guaranteed, improving the cluster's fault tolerance and reliability. Attached Figure Description

[0025] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.

[0026] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0027] Figure 1 A flowchart illustrating the network packet processing method provided in this embodiment of the disclosure;

[0028] Figure 2 A structural connection diagram of the network packet processing apparatus provided in the embodiments of this disclosure;

[0029] Figure 3 This is a structural connection diagram of a computer device provided in an embodiment of the present disclosure. Detailed Implementation

[0030] To better understand the above-mentioned objectives, features, and advantages of this disclosure, the solutions disclosed herein will be further described below. It should be noted that, unless otherwise specified, the embodiments and features described herein can be combined with each other.

[0031] Numerous specific details are set forth in the following description to provide a thorough understanding of this disclosure, but this disclosure may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only a part of the embodiments of this disclosure, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure.

[0032] It should be noted that, in this document, relational terms such as "first" and "second" are used merely 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. Unless otherwise specified, 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 the element.

[0033] Before describing the embodiments of this disclosure in detail, a brief introduction to the technical terms used in this disclosure is given below.

[0034] Tengine_host refers to the host running the Tengine server. Tengine_host is a Layer 7 cloud network load balancing cloud gateway, acting as the entry point for network traffic and responsible for routing, filtering, and managing data flows entering and leaving the network. The Tengine server is a high-performance web server and reverse proxy server based on Nginx, optimized for handling large-scale, high-concurrency scenarios, and widely used in e-commerce, cloud computing, and other fields.

[0035] LocalIP: This is the address identifier of the host (Tengine_host) in the local network. Devices within the same local area network communicate with each other through LocalIP.

[0036] XGW stands for Layer 4 Cloud Gateway, which is the entry point for network traffic and is responsible for routing, filtering, and managing data flows into and out of the network.

[0037] LVS-agent: This is short for Load Balancing Virtual Server Agent. It is responsible for configuring and managing the load balancer, ensuring high availability of services and the correct implementation of load balancing strategies. It is mainly responsible for distributing XGW cloud gateway configurations.

[0038] According to an embodiment of this disclosure, a method for processing network packets is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0039] This embodiment provides a method for processing network packets, which can be used in a cloud gateway XGW. The XGW is equipped with a Tengine cluster, and the Tengine cluster includes at least a first host device and a second host device. Figure 1 This is a flowchart of a network packet processing method according to an embodiment of the present disclosure, such as... Figure 1 As shown, the process includes the following steps:

[0040] S101, Receive the first message.

[0041] S102, according to the preset algorithm, determine the first LocalIP address from the local Internet Protocol LocalIP addresses corresponding to the first host device and the second host device respectively, and encapsulate the first LocalIP address in the first message to obtain the second message.

[0042] The first host device operates in a first listening mode, which supports listening to multiple LocalIP addresses; the second host device operates in a second listening mode, which supports listening to one LocalIP address.

[0043] It should be noted that different listening modes correspond to different LocalIP addresses. For example, when the first host device operates in the first listening mode, it corresponds to multiple pre-configured LocalIP addresses. A mode that supports listening to multiple LocalIP addresses means that the first host device can receive packets through multiple pre-configured LocalIP addresses. When the second host device operates in the second listening mode, it corresponds to a single pre-configured LocalIP address. A mode that supports listening to only one LocalIP address means that the second host device can only receive packets through that single pre-configured LocalIP address.

[0044] The preset algorithm refers to the load balancing algorithm pre-configured by the cloud gateway XGW. For example, the preset algorithm includes, but is not limited to, round-robin, weighted round-robin, and least-connection algorithms.

[0045] The first LocalIP address refers to the LocalIP address selected from the LocalIP addresses of the first host device and the second host device respectively by a preset algorithm.

[0046] Specifically, when the cloud gateway XGW receives the first packet, it determines the first LocalIP address from the multiple LocalIP addresses corresponding to the first host device and the unique LocalIP address corresponding to the second host device according to the pre-configured load balancing algorithm (i.e., the preset algorithm). The first LocalIP address is then encapsulated as the destination IP in the first packet to obtain the second packet.

[0047] S103, when the first LocalIP address is one of the multiple LocalIP addresses corresponding to the first host device, forward the second message to the first host device.

[0048] Specifically, when the first LocalIP address encapsulated in the second message is one of the multiple LocalIP addresses corresponding to the first host device, the second message is forwarded to the first host device.

[0049] Alternatively, in S104, when the first LocalIP address is the unique LocalIP address corresponding to the second host device, the second message is forwarded to the second host device.

[0050] Specifically, when the first LocalIP address encapsulated in the second message is the unique LocalIP address corresponding to the second host device, the second message is forwarded to the second host device.

[0051] The network packet processing method disclosed herein operates the first and second host devices in the Tengine cluster under different listening modes. Since the first host device in the Tengine cluster operates in a first listening mode that supports listening to multiple LocalIP addresses, the cloud gateway XGW can forward packets to the first host device through multiple LocalIP addresses. Compared to the current cloud gateway XGW, which can only forward packets to the first host device through a single LocalIP address, the solution provided herein can distribute more packets to the first host device operating in the first listening mode, thereby alleviating the risk of host overload during periods of high traffic. Furthermore, in this scenario, even if the listening methods of other host devices fail, the overall processing capacity of the cluster can still be guaranteed, improving the cluster's fault tolerance and reliability.

[0052] Furthermore, after receiving the first message, when the first host device is overloaded, the network message processing method further includes: receiving a third message; when the total number of messages received by the first host device exceeds a first preset threshold, and the first host device switches from a first listening mode to a second listening mode, determining a second LocalIP address from the LocalIP addresses corresponding to the first host device and the second host device respectively, and encapsulating the second LocalIP address in the third message to obtain a fourth message; when the second LocalIP address is the unique LocalIP address corresponding to the first host device, forwarding the fourth message to the first host device.

[0053] The total number of packets received by the first host device refers to the total number of packets received by the first host device per unit time. The first preset threshold is the upper limit of the number of packets that the first host device can receive per unit time. When the total number of packets received by the first host device exceeds the first preset threshold, it indicates that the first host device is overloaded. The first host device is not only prone to packet loss but also to host device failure. In the case of overload, the first host device's listening mode is switched from the first listening mode to the second listening mode. By reducing the number of packets forwarded to the first host device, the overload problem of the first host device is alleviated.

[0054] Specifically, the cloud gateway receives the third message. If the total number of messages received by the first host device exceeds a first preset threshold, and the first host device switches from a first listening mode to a second listening mode, the second LocalIP address is determined from the unique LocalIP address corresponding to the first host device and the second LocalIP address corresponding to the second host device (which may be a unique LocalIP address or multiple LocalIP addresses). The second LocalIP address is encapsulated in the third message to obtain the fourth message. When the second LocalIP address is the unique LocalIP address corresponding to the first host device, the fourth message is forwarded to the first host device.

[0055] It's important to note that the switching of listening modes between host devices is independent. A change in the listening mode of the first host device may not necessarily cause a change in the listening mode of the second host device. Changes in the listening mode of the second host device may be related to whether its corresponding LocalIP address is experiencing traffic overload.

[0056] The network packet processing method provided in this embodiment, when the total number of packets received by the first host device exceeds a first preset threshold and the first host device switches from a first monitoring mode to a second monitoring mode, allows the cloud gateway XGW to forward packets to the first host device only through the unique LocalIP address corresponding to the first host device. This embodiment's solution, through flexible switching of monitoring modes, reduces the number of packets forwarded to the first host device by the cloud gateway XGW, solving the problem of traffic overload on the first host device, reducing packet loss or congestion caused by traffic overload, improving packet transmission efficiency and service continuity, and also enhancing the flexibility of the Tengine cluster in coping with complex network environments and changing traffic demands.

[0057] Optionally, when the total number of packets received by the first host device exceeds the first preset threshold, the number of packets forwarded to the first host device can be reduced by adding a third host device in the Tengine cluster, thereby alleviating the load on the first host device.

[0058] For example, after adding a third host device to the Tengine cluster, the third host device can be configured to listen in the second mode by default, and a unique LocalIP can be configured for it. When the traffic received by the third host device carrying its configured unique LocalIP address becomes overloaded, the traffic overload problem can be alleviated by switching the corresponding listening mode of the third host device.

[0059] Optionally, the monitoring mode switching method can be as follows: when the monitoring component in the cloud gateway XGW detects that the total number of packets received by the first host device exceeds the first preset threshold, the application interface provided by the first host device is called to switch the monitoring mode of the first host device from the first monitoring mode to the second monitoring mode, and the multiple LocalIPs corresponding to the first host device in the first monitoring mode are switched to the unique LocalIP corresponding to the second monitoring mode.

[0060] Simultaneously, the cloud gateway XGW modifies the configuration information of the pre-stored first host device. Specifically, it changes the first listening mode in the configuration information to the second listening mode, and switches the multiple LocalIP addresses corresponding to the first host device in the first listening mode to the unique LocalIP address corresponding to the first host device in the second listening mode. This synchronized modification of the cloud gateway XGW and the first host device ensures consistency between them.

[0061] Furthermore, after the first host device switches its listening mode from the first listening mode to the second listening mode, if the unique LocalIP address corresponding to the first host device in the second listening mode also experiences traffic overload, the network packet processing method further includes: receiving a fifth packet; when the packet traffic carrying the second LocalIP received by the first host device exceeds the second preset threshold, and the first host device switches back from the second listening mode to the first listening mode, determining the third LocalIP address from the LocalIP addresses corresponding to the first host device and the second host device respectively, and encapsulating the third LocalIP address in the fifth packet to obtain a sixth packet; when the third LocalIP address is one of the multiple LocalIP addresses corresponding to the first host device, forwarding the sixth packet to the first host device.

[0062] First, it's important to clarify that overload of the first host device and overload of the unique LocalIP address corresponding to the first host device are different. Overload of the first host device refers to the packet traffic forwarded to the first host device exceeding its carrying capacity (i.e., the first preset threshold). Overload of the unique LocalIP address corresponding to the first host device refers to the traffic carrying that unique LocalIP address exceeding the bandwidth limit corresponding to that LocalIP address. The second preset threshold is the maximum number of packets within the allowed bandwidth range. The first preset threshold is greater than or equal to the second preset threshold.

[0063] The packet traffic carrying the second LocalIP received by the first host device refers to the packet traffic carrying the second LocalIP address received by the first host device per unit time. The second preset threshold refers to the maximum packet capacity corresponding to the bandwidth of the second LocalIP address per unit time, ensuring normal packet transmission. The second preset threshold can be set according to the actual LocalIP bandwidth; this embodiment does not limit this setting.

[0064] Specifically, upon receiving the fifth message: If the packet traffic carrying the second LocalIP address received by the first host device exceeds a second preset threshold, and the first host device switches back from the second listening mode to the first listening mode, the third LocalIP address is determined from the multiple LocalIP addresses corresponding to the first host device in the first listening mode and the LocalIP addresses corresponding to the second host device (which may be a unique LocalIP address or multiple LocalIP addresses). The third LocalIP address is encapsulated in the fifth message to obtain the sixth message. When the third LocalIP address is one of the multiple LocalIP addresses corresponding to the first host device, the sixth message is forwarded to the first host device.

[0065] The network packet processing method provided in this embodiment, when the packet traffic carrying the second LocalIP address received by the first host device exceeds the first preset threshold, and the first host device switches from the second monitoring mode back to the first monitoring mode, the cloud gateway XGW forwards the packet to the first host device through multiple LocalIP addresses corresponding to the first host device. This embodiment achieves the purpose of traffic diversion by increasing the number of LocalIP addresses, so as to solve the problem of traffic overload corresponding to the second LocalIP address.

[0066] In some optional embodiments, the control method for the listening mode has been optimized. Before receiving the first packet, the network packet processing method further includes: when the target switch of the first host device is set to the on state, the first host device operates in a first listening mode; when the target switch of the second host device is set to the off state, the second host device operates in a second listening mode.

[0067] The target switch is used to enable either the first listening mode or the second listening mode.

[0068] Optionally, the configuration information of the target switches corresponding to each host in the Tengine cluster is sent by the operations and maintenance personnel to the LVS-agent component of the cloud gateway XGW. The configuration information of the target switches is the on / off status of the target switches.

[0069] For example, when the target switch's configuration information is enable_local_ip=true, it indicates that the target switch is in the on state. When the target switch's configuration information is enable_local_ip=false, it indicates that the target switch is in the off state. The identifier corresponding to the target switch's on / off state can be defined by the operations and maintenance personnel.

[0070] When the cloud gateway XGW forwards a packet to a host device, a listener bound to that host device monitors the packets being forwarded to it. Upon detecting that a packet has arrived at the host device, the listener triggers the host device to process the packet. Therefore, before S101, a binding relationship needs to be established between the listener and the host device. Here, the host device refers to each of the multiple host devices under the Tengine cluster. The following embodiment will use the first host device as an example to illustrate the binding process between the listener and the first host device.

[0071] In some optional embodiments, the first host device is bound to a listener, and the number of listeners bound to the first host device is the same as the number of LocalIP addresses corresponding to the first host device; for each listener, the fourth LocalIP address bound to the listener and the port corresponding to the fourth LocalIP address are determined based on the index field pre-configured by the listener and the local network address range pre-configured by the first host device.

[0072] The fourth LocalIP address is one of the multiple LocalIP addresses corresponding to the first host device when it is operating in the first listening mode.

[0073] Optionally, the network address range is described using CIDR notation.

[0074] Specifically, the listener's index field `local_ip_index` is transmitted by the operations and maintenance personnel to the service component `server` deployed at the Tengine cluster entry point. Each listener has a unique corresponding index field `local_ip_index`. The range of the `local_ip_index` field can be set according to customer needs; for example, the range of `Local_ip_index` can be set between 0 and 20000.

[0075] Specifically, the local network address range (local_cidrs) for each host device is transmitted by the operations and maintenance personnel to the LVS-agent component deployed in the cloud gateway XGW. The LVS-agent component then encapsulates the local network address range (local_cidrs) for each host device into a LocalVipGen class. The LocalVipGen class is a generator used to generate LocalIP address and port combinations, implemented in Python. This LocalVipGen class contains all the LocalIPs and ports within the local network address range (local_cidrs) for the first host device.

[0076] Optionally, the fourth LocalIP address and port are determined from available IP addresses based on the index field; the available IP addresses are obtained from a network object, which is converted from the local network address range by the IPNetwork module in the netaddr toolkit.

[0077] Specifically, when the LVS-agent component sends configuration (i.e., the LocalIP address) to the first host device, the LocalVipGen class uses the IPNetwork module from the third-party toolkit netaddr to initialize and encapsulate the local network address range local_cidrs (containing all available IP addresses), and converts the local network address range local_cidrs into a network object stored in the network variable. This network object contains all the information within the local network address range local_cidrs (such as network address, broadcast address, subnet mask, etc.). Then, through a callback function, the listener's index field local_ip_index is used as input to obtain the fourth LocalIP address and port corresponding to the index field. A mapping relationship is established between the index field and the fourth LocalIP address and port, completing the binding between the listener and the first host device.

[0078] The network packet processing method provided in this embodiment determines the fourth LocalIP address bound to the listener and the port corresponding to the fourth LocalIP address based on the index field pre-configured by the listener and the local network address range pre-configured by the first host device. Through automated and simplified configuration management, it ensures the efficiency of the configuration process, reduces the workload of operation and maintenance personnel, and reduces the occurrence of human error.

[0079] This embodiment also provides a network packet processing apparatus for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0080] This embodiment provides a network packet processing device, such as... Figure 2 As shown, it includes:

[0081] This disclosure provides a network packet processing apparatus, the apparatus comprising:

[0082] The first receiving module 201 is used to receive the first message.

[0083] The first determining module 202 is used to determine the first LocalIP address from the local Internet Protocol (IP) addresses corresponding to the first host device and the second host device respectively according to a preset algorithm, and encapsulate the first LocalIP address in a first message to obtain a second message.

[0084] The first forwarding module 203 is used to forward the second message to the first host device when the first LocalIP address is one of the multiple LocalIP addresses corresponding to the first host device.

[0085] Alternatively, the second forwarding module 204 is used to forward a second packet to the second host device when the first LocalIP address is the unique LocalIP address corresponding to the second host device; wherein the first host device operates in a first listening mode, which supports listening to multiple LocalIP addresses; and the second host device operates in a second listening mode, which supports listening to one LocalIP address.

[0086] In some alternative embodiments, the apparatus further includes:

[0087] The second receiving module is used to receive a third message after receiving the first message; the second determining module is used to determine a second LocalIP address from the LocalIP addresses corresponding to the first host device and the second host device respectively when the packet traffic carrying the target LocalIP address received by the first host device exceeds a first preset threshold and the first host device switches from the first listening mode to the second listening mode, and encapsulates the second LocalIP address in the third message to obtain a fourth message; wherein the target LocalIP address is one of the multiple LocalIP addresses corresponding to the first host device when it is in the first listening mode; the third forwarding module is used to forward the fourth message to the first host device when the second LocalIP address is the unique LocalIP address corresponding to the first host device.

[0088] In some alternative embodiments, the apparatus further includes:

[0089] The third receiving module is used to receive the fifth message; the third determining module is used to determine the third LocalIP address from the LocalIP addresses corresponding to the first host device and the second host device respectively when the packet traffic carrying the second LocalIP received by the first host device exceeds the first preset threshold and the first host device switches from the second listening mode back to the first listening mode, and encapsulates the third LocalIP address in the fifth message to obtain the sixth message; the fourth forwarding module is used to forward the sixth message to the first host device when the third LocalIP address is one of the multiple LocalIP addresses corresponding to the first host device.

[0090] In some optional implementations, before receiving the first message, the first host device operates in a first listening mode when the target switch of the first host device is set to the open state; and the second host device operates in a second listening mode when the target switch of the second host device is set to the closed state; wherein the target switch is used to enable the first listening mode or the second listening mode.

[0091] In some optional implementations, the first host device is bound to a listener, and the number of listeners bound to the first host device is the same as the number of LocalIP addresses corresponding to the first host device; for each listener, the fourth LocalIP address bound to the listener and the port corresponding to the fourth LocalIP address are determined based on the index field pre-configured by the listener and the local network address range pre-configured by the first host device; wherein, the fourth LocalIP address is one of the multiple LocalIP addresses corresponding to the first host device.

[0092] In some optional implementations, the network address range is described using CIDR notation; the fourth LocalIP address bound to the listener and the port corresponding to the fourth LocalIP address are determined based on the listener's pre-configured index field and the first host device's pre-configured local network address range, specifically:

[0093] The fourth LocalIP address and port are determined from the available IP addresses based on the index field; the available IP addresses are obtained from the network object, which is converted from the local network address range by the IPNetwork module in the netaddr toolkit.

[0094] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.

[0095] In this embodiment, the network packet processing device is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.

[0096] This disclosure also provides a computer device having the above-described features. Figure 2 The device shown is for processing network packets.

[0097] Please see Figure 3 , Figure 3 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of this disclosure, such as... Figure 3As shown, the computer device includes one or more processors 301, memory 302, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 3 Take processor 301 as an example.

[0098] Processor 301 may be a central processing unit, a network processor, or a combination thereof. Processor 301 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.

[0099] The memory 302 stores instructions executable by at least one processor 301 to cause at least one processor 301 to perform the method shown in the above embodiments.

[0100] Memory 302 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, memory 302 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, memory 302 may optionally include memory remotely located relative to processor 301, and this remote memory may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0101] Memory 302 may include volatile memory, such as random access memory; memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; memory 302 may also include combinations of the above types of memory.

[0102] The computer device also includes a communication interface 303 for communicating with other devices or communication networks.

[0103] This disclosure also provides a computer-readable storage medium in which the methods described in this disclosure can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code originally stored on a remote storage medium or a non-transitory machine-readable storage medium and subsequently stored on a local storage medium after being downloaded over a network. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium may be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium may also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code that, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.

[0104] In addition to the computer devices and computer-readable storage media described above, embodiments of this application may also be computer program products, which include computer program instructions that, when executed by a processor, cause the processor to perform the steps of the sound source localization method provided in any embodiment of this application.

[0105] Computer program products can be written in any combination of one or more programming languages ​​to perform the operations of the embodiments of this application. The programming languages ​​include object-oriented programming languages ​​such as Java and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computing device, partially on the user's computing 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.

[0106] The above are merely specific embodiments of this disclosure, enabling those skilled in the art to understand or implement this disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not to be limited to these embodiments, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for processing network packets, characterized in that, The method is applied to a cloud gateway XGW, wherein the XGW is mounted with a Tengine cluster, and the Tengine cluster includes at least a first host device and a second host device. The method includes: Receive the first message; According to the preset algorithm, the first LocalIP address is determined from the local Internet Protocol (LocalIP) addresses corresponding to the first host device and the second host device respectively, and the first LocalIP address is encapsulated in the first message to obtain the second message. The preset algorithm refers to the load balancing algorithm pre-configured by the cloud gateway XGW. When the first LocalIP address is one of the multiple LocalIP addresses corresponding to the first host device, the second packet is forwarded to the first host device. Alternatively, when the first LocalIP address is the unique LocalIP address corresponding to the second host device, the second packet is forwarded to the second host device; The first host device operates in a first listening mode, which supports listening to multiple LocalIP addresses; the second host device operates in a second listening mode, which supports listening to one LocalIP address. After receiving the first message, the method further includes: Receive third message; When the total number of messages received by the first host device exceeds the first preset threshold, and the first host device switches from the first listening mode to the second listening mode, the second LocalIP address is determined from the LocalIP addresses corresponding to the first host device and the second host device respectively, and the second LocalIP address is encapsulated in the third message to obtain the fourth message; When the second LocalIP address is the unique LocalIP address corresponding to the first host device, the fourth message is forwarded to the first host device.

2. The method according to claim 1, characterized in that, The method further includes: Received the fifth message; When the packet traffic carrying the second LocalIP received by the first host device exceeds the second preset threshold, and the first host device switches from the second listening mode back to the first listening mode, the third LocalIP address is determined from the LocalIP addresses corresponding to the first host device and the second host device respectively, and the third LocalIP address is encapsulated in the fifth packet to obtain the sixth packet; When the third LocalIP address is one of the multiple LocalIP addresses corresponding to the first host device, the sixth message is forwarded to the first host device.

3. The method according to any one of claims 1-2, characterized in that, When the target switch of the first host device is set to the on state, the first host device operates in the first monitoring mode; When the target switch of the second host device is set to the off state, the second host device operates in the second monitoring mode; The target switch is used to enable either the first monitoring mode or the second monitoring mode.

4. The method according to any one of claims 1-2, characterized in that, The first host device is bound to a listener, and the number of listeners bound to the first host device is the same as the number of LocalIP addresses corresponding to the first host device; For each of the listeners, the fourth LocalIP address bound to the listener and the port corresponding to the fourth LocalIP address are determined based on the index field pre-configured by the listener and the local network address range pre-configured by the first host device. The fourth LocalIP address is one of the multiple LocalIP addresses corresponding to the first host device.

5. The method according to claim 4, characterized in that, The network address range is described using CIDR notation; The fourth LocalIP address bound to the listener and the port corresponding to the fourth LocalIP address are determined based on the index field pre-configured by the listener and the local network address range pre-configured by the first host device, specifically as follows: The fourth LocalIP address and the port are determined from available IP addresses based on the index field; The available IP address is obtained from a network object, which is obtained by converting the local network address range using the IPNetwork module in the netaddr toolkit.

6. A network packet processing apparatus, characterized in that, The device is applied to a cloud gateway XGW, the XGW being mounted with a Tengine cluster, the Tengine cluster including at least a first host device and a second host device, and the device comprising: The first receiving module is used to receive the first message; The first determining module is used to determine a first LocalIP address from the local Internet Protocol LocalIP addresses corresponding to the first host device and the second host device respectively according to a preset algorithm, and encapsulate the first LocalIP address in the first message to obtain a second message. The preset algorithm refers to the load balancing algorithm pre-configured by the cloud gateway XGW. The first forwarding module is used to forward the second packet to the first host device when the first LocalIP address is one of a plurality of LocalIP addresses corresponding to the first host device. Alternatively, the second forwarding module is used to forward the second packet to the second host device when the first LocalIP address is the unique LocalIP address corresponding to the second host device; The first host device operates in a first listening mode, which supports listening to multiple LocalIP addresses; the second host device operates in a second listening mode, which supports listening to one LocalIP address. The second receiving module is used to receive the third message after receiving the first message; The second determining module is used to determine the second LocalIP address from the LocalIP addresses corresponding to the first host device and the second host device respectively when the total number of messages received by the first host device exceeds the first preset threshold and the first host device switches from the first listening mode to the second listening mode, and encapsulate the second LocalIP address in the third message to obtain the fourth message. The third forwarding module is used to forward the fourth message to the first host device when the second LocalIP address is the unique LocalIP address corresponding to the first host device.

7. A computer device, characterized in that, include: A memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, the processor executing the computer instructions to perform the method of any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to perform the method of any one of claims 1 to 5.

9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.