1. Field of the Invention
The present invention relates to a method for processing packets in a network, and more particularly to a method for processing network traffic loading balance.
2. Related Art
With the increasing growth of Internet, network transmission technology also develops quickly. Thus, many network equipments are added with the loading balance function. The loading balance for network transmission mainly refers to the network equipment assigning queues to store data packets and processing the packets with corresponding threads on receiving a large flow of data packets. The data packets are simultaneously processed by a plurality of threads to prevent the limitation of a single processing thread. Meanwhile, the accuracy of data packet processing is guaranteed by ensuring the integrity of the session.
However, the conventional loading balance still has disadvantages.
In order to solve the above problems, the present invention is mainly directed to a method for processing network traffic loading balance so as to balance the load of a session of various threads in a network equipment.
Therefore, a method for processing network traffic loading balance is provided. The method includes the steps of: executing a plurality of threads each for processing the data packets of a session, and assigning a queue to each thread for storing the data packets; setting an operating threshold value; determining whether the number of the data packets in the queue satisfies the operating threshold value; and if the number of the data packets in the queue satisfies the operating threshold value, forwarding by a server the data packets in a queue to the other queues for storing according to a transmission attribute of the session.
The method for processing data packet loading balance provided by the present invention is used for preventing a large number of data packets from flowing into a single queue. Besides, in addition to maintaining the integrity of the session, the stability of packet processing is also ensured during a large traffic.
The present invention will become more fully understood from the detailed description given herein below for illustration only, which thus is not limitative of the present invention, and wherein:
The present invention is applicable to a network equipment with packet exchange. The network equipment is, for example but not limited to, an intrusion detection system (IDS), firewall, and intrusion prevention system (IPS).
After the establishment of the session and the execution of the threads, the server establishes the session lookup table 223 and the packet fragment lookup table 224 respectively according to the received data packets.
Following Step S320, an operating threshold value is set (Step S330) for determining whether the queue is able to store more currently received data packets. The operating threshold value is set according to the relative proportion between the number of the data packets in the queue and the maximum volume of the queue. For example, if the queue is capable of containing 100 data packets and the queue has already received 70 data packets, the volume of the queue is defined as 70/100=70%. Assume that the operating threshold value is 60%, and the above volume of the queue has exceeded the threshold. Afterward, a cycle time is set (Step S340) to determine a time interval for the network equipment to detect the number of the data packets in each queue. Then, it is determined whether the number of the data packets in the queue satisfies the operating threshold value (Step S350).
If the number of the data packets in the queue has not reached the operating threshold value, the network equipment sends the data packets to the corresponding queue according to a preset procedure (Step S360). If the number of the data packets in the queue satisfies the operating threshold value, the network equipment forwards the data packets in the queue to the other queues for storing according to the preset procedure and the transmission attributes of the session (Step S370). In this embodiment, the preset procedure selects the queue to be forwarded to according to Equation 1 below:
Q_num=(src_IP&0×FF)+(dst_IP&0×FF)% n+1 (Equation 1)
In the equation, Q_num is the number of the destination queue to be forwarded to, scr_IP is the IP address of a source, dst_IP is the LP address of a destination, and n is the number of the queues.
Further referring to
The following example is given to clearly describe the operating process of the present invention.
((218.30.108.184)&0×FF+(10.190.50.39)&0×FF)% 6+1=2 (Equation 2)
After the cycle time, the data packet volume of each queue in the network equipment is stated in Table 1 as follows:
Seen from Table 1, the volume of the first queue has exceeded the operating threshold value. Therefore, when receiving a new data packet (defined herein as a first data packet), the network equipment 220 selects another queue for storing the first data packet. It is assumed that the source of the first data packet is src_ip: 223.40.106.183, src_port: 80, and the destination thereof is dst_ip: 10.190.50.39, dst_port: 3000.
If the first data packet belongs to a new session, the network equipment 220 calculates the queue for storing the first data packet according to Equation 1. Equation 3 is given as follows:
((223.40.106.183)&0×FF+(10.190.50.39)&0×FF) % 6+1=1 (Equation 3)
According to Equation 3, it is derived that the first data packet is to be stored in the first queue. However, as the first queue has exceeded the operating threshold value, the network equipment 220 selects one from the other queues with the lowest volume. Seen from Table 1, the sixth queue has the lowest volume at present. Therefore, the network equipment 220 stores the first data packet in the sixth queue. Moreover, the network equipment 220 records related information about the first data packet in the session lookup table 223. For the ease of description, the session lookup table 223 of this embodiment adopts the following recording format.
When receiving a second and a third data packet with a fragment identifier of the same group, the network equipment 220 stores the second and the third data packet to the sixth queue according to the context of the first data packet, and records the second and the third data packet in the packet fragment lookup table 224. Assume that the fragment identifier is “1234567”, and the packet fragment table is as shown in
The method for processing data packet loading balance provided by the present invention is used for preventing a large number of data packets from flowing into a single queue. Besides, in addition to maintaining the integrity of the session, the stability of packet processing is also ensured during a large traffic.