Background technology
In order to improve the fail safe of network, some safety monitoring devices are used for customer flow is monitored in real time, can improving constantly along with network speed; The continuous growth of traffic carrying capacity and data traffic; Single server can't be born at all,, will cause the wasting of resources and input cost higher if carry out HardwareUpgring to equipment this moment; To this situation, the method for some load balancing is arisen at the historic moment.
The method of load balancing is a kind of cheapness, effective, transparent method, can expand the bandwidth of conventional network equipment and server, increases throughput, strengthens the network data-handling capacity, improves network more flexible and availability.The cardinal principle of load balancing is: the data flow of express network is delivered to load equalizer, and load equalizer is realized flow equalization and monitoring to express network according to someway the high-speed data-flow equilibrium being assigned on the server of many low speed.So load-balancing method is most important in load equalizer.
Present load-balancing method mainly contains static equilibrium and dynamic equalization; The static equilibrium method mainly contains: Hash equalization algorithm (Hash operation), static priority scheduling algorithm, polling dispatching algorithm, weight polling dispatching algorithm, method for dynamically balancing mainly contains: minimum linking number equalization algorithm and fastest response time equalization algorithm.Estimating a good and bad important indicator of a kind of load-balancing method is exactly equilibrium degree
L, i.e. bandwidth availability ratio deviation between each server, its computing formula is:
, wherein
Flow1,
Flow2Be the present flow rate value of two passages,
FlowIt is the average ideal flow value of two passages.More than various load-balancing methods to each server-assignment data traffic the time, all do not consider the present flow rate loading condition of each server, so there is the not high problem of equilibrium degree between each server.
Summary of the invention
The objective of the invention is to have proposed a kind of load-balancing method of express network in order to solve the not high problem of existing load-balancing method equilibrium degree.
To achieve these goals, technical scheme of the present invention is: a kind of load-balancing method of express network specifically comprises the steps:
S1. IP data packet header information extraction comprises and extracts source IP address, purpose IP address, source port number, destination slogan;
S2. Hash operation is carried out Hash operation to the IP header message of extracting, and asks mould to get remainder to 4 the result of Hash operation, and the indication information that comes the distributing IP packet according to the value of asking mould to draw is in corresponding storage queue;
S3. formation distribution and storage administration comprises the write operation management and the read operation management of formation;
S4. polymorphic parallel sorting and scheduling; This process is according to the sky of each formation feedback, full state information and port flow indication information; Through controlling the time interval between the polling operation twice, adopt preferential and preferential each formation of tactful poll of full queue of minimum discharge, poll is read the indication information that corresponding IP divides into groups from each formation; From data buffer, read corresponding packet according to indication information, be forwarded on the corresponding target port.Specifically comprise the steps:
When S41. having transmitted a data grouping at every turn, preserve port flow information and also inquire each formation;
S42. at first judge whether to exist full queue; If exist, judge whether again to have a plurality of full queues, if having only a full queue; Just calculate its corresponding poll stand-by period; Start the stand-by period timer, arrive poll during the stand-by period, the packet of transmitting this full queue is to the corresponding target port; If there are a plurality of full queues; According to the value of transmission data flow of these several full queue statistics, choose the minimum formation of full queue middle port flow value, calculate its poll stand-by period; Start the stand-by period timer; Arrive poll transmits this formation during the stand-by period packet to the corresponding target port, in addition, if there is the data flow value of plural formation to equate in a plurality of full queue; And their flow value is minimum, and the packet of then transmitting the minimum full queue of port numbers is to the corresponding target port; If there is not full queue, choose the non-empty queue in all formations;
S43. compare the data flow value that each non-empty queue has been sent; Judge that the flow value that whether has only a formation in the non-empty queue is minimum; If, just calculate poll stand-by period of this formation, start the stand-by period timer; Arrive poll during the stand-by period, just directly transmit the corresponding packet of this formation to the corresponding target port; Otherwise, choose the minimum formation of port numbers, calculate its poll stand-by period, start the stand-by period timer, reach poll during the stand-by period, transmit the corresponding packet of this formation to the corresponding target port.
Among the step S2, described Hash operation is the IPSX hash algorithm.
Beneficial effect of the present invention: utilization of the present invention combines static equilibrium with the dynamic self-adapting equilibrium dynamic self-adapting Hash balance policy; The express network load-balancing method that static Hash equalization algorithm of a kind of front end utilization and rear end utilize polymorphic parallel sorting and dispatching algorithm has been proposed; This method has been utilized the present flow rate loading condition; Make high-speed data-flow equilibrium to be assigned on a plurality of slow network interfaces, improve the mutual equilibrium degree of each sub-channel.
Embodiment
Below in conjunction with accompanying drawing, provide specific embodiment of the present invention.Need to prove: the parameter among the embodiment does not influence generality of the present invention.
High speed data network with two-channel 2-4 .5G (OC-48 interface, VC-4-16C concatenation technology); Two-channel 2-4 .5G data flow is balanced to 8 gigabit Ethernet (GBE; GigaBit Ethernet) is example on the interface, supposes that the system that realizes this method is called equalizer.
Concrete design philosophy of the present invention is: adopt the dynamic self-adapting Hash (HBDC that static equilibrium is combined with the dynamic self-adapting equilibrium; Hash Balancing and Dynamic Compensation) balance policy; Promptly be that the equalizer front end adopts the Hash equalization algorithm that high-speed data-flow is mapped in each formation; Each queue stores be Internet protocol (IP; Internet Protocol) indication information of data, IP data division are buffered in the data buffer, realize that long-term statistic flow is balanced; Polymorphic parallel sorting and dispatching algorithm are adopted in the equalizer rear end; According to minimum preferential and each formation of full queue principle of priority poll of flow; From formation, read the indication information of IP data; From data buffer, take out corresponding IP data again, IP traffic is assigned on the corresponding GBE port, realize the instantaneous flow equalization of express network according to the port indication information.
Specifically as shown in Figure 1: the header message that at first extracts the IP packet; Its header message is carried out Hash operation; Simultaneously with in IP storage to the data buffer; According to the Hash operation result length of two-channel 2-4 .5G High Speed IP data and the indication informations such as storage first address in buffer thereof are assigned in 8 formations, have guaranteed the correlation of the sequencing and the stream of message, realize long-term static equilibrium two-channel 2-4 .5G data flow; Polymorphic parallel sorting and dispatching algorithm are adopted in the rear end; Realize polling dispatching according to the minimum principle of priority of flow to 8 formations; Poll is read the indication information of the IP data in each formation, according to corresponding IP data in the indication information sense data buffer, and sends on the corresponding GBE port; On the GBE port,, realize that the transient behavior of flow is balanced to the reorganization of classifying of IP data and indication information thereof.Corresponding GBE port of each formation wherein.The pointer information that returns according to polymorphic parallel sorting and scheduling and the full state information control of sky of 8 formations are to the write operation of 8 formations.
Below in conjunction with Fig. 2, Fig. 3 express network load balancing process is described further, specifically comprises the steps:
S1. IP data packet header information extraction to each 2.5G high-speed data channel, is extracted source IP address, purpose IP address, source port number, destination slogan;
S2. Hash operation.Header message to extracting the IP packet is carried out Hash operation, asks mould to get remainder to 4 the result of Hash operation, and the indication information that comes the distributing IP packet according to the value of asking mould to draw is in corresponding storage queue.
When above-mentioned Hash operation is the IPSX hash algorithm, the best performance that is reached.Because the IPSX hash algorithm is the existing known technology of this area, therefore do not remake detailed description here.
S3. formation distribution and storage administration.This process comprises two aspects: the write operation management of formation and read operation management.As shown in Figure 2; The implementation process of write operation is: produce writing of respective queue according to the state information of each formation feedback and Hash operation result and enable; As: when the Hash operation result is that 0 and 0 formation is not also write and just produced writing of formation 0 when full and enable, write the indication information of corresponding IP data to formation 0; In like manner, produce writing of other 7 formations and enable, write the indication information of corresponding IP data to each formation.The implementation process of read operation is mainly accomplished according to the polymorphic parallel sorting and the scheduling of back.
S4. polymorphic parallel sorting and scheduling.This process is according to the full state information of sky of each formation feedback; Through controlling the time interval between the polling operation twice; Adopt preferential each formation of tactful poll of minimum discharge; Poll is read the indication information that corresponding IP divides into groups from each formation, from data buffer, reads corresponding packet according to indication information, is forwarded on the corresponding GBE port.As shown in Figure 3, specifically comprise the steps:
When S41. having transmitted a data grouping, the storage port flow information is also inquired 8 formations at every turn;
S42. at first judge whether to exist full queue,, judge whether to exist a plurality of full queues again if exist; If have only a full queue; Just calculate its corresponding poll stand-by period, start the stand-by period timer, arrive poll during the stand-by period; Carry out corresponding read operation, the packet of transmitting this full queue is to corresponding GBE port; If there are a plurality of full queues; According to the value of transmission data flow of these several full queue statistics, choose the minimum formation of full queue middle port flow value, calculate its poll stand-by period; Start the stand-by period timer; Arrive poll during the stand-by period, carry out corresponding read operation, the packet of transmitting this formation is to corresponding GBE port; In addition, if there is the data flow value of plural formation to equate in a plurality of full queue, and their flow value is minimum, carries out corresponding read operation, and the packet of transmitting the minimum full queue of port numbers is to corresponding GBE port; As do not have full queue, and in non-empty queue, select the minimum formation of port flow, carry out corresponding read operation, the packet of transmitting this formation is to corresponding GBE port;
S43. compare the data flow value that each non-empty queue has been sent; Judge that the flow value that whether has only a formation in the non-empty queue is minimum; If, just calculate poll stand-by period of this formation, start the stand-by period timer; Arrive poll during the stand-by period, just directly transmit the corresponding packet of this formation to corresponding GBE port; Otherwise, choose the minimum formation of port numbers, calculate its poll stand-by period, start the stand-by period timer, reach poll during the stand-by period, transmit the corresponding packet of this formation to corresponding GBE port.
Need to prove: 8 shared traffic statistics time timers of formation in the present embodiment, as shown in Figure 3, when beginning to send the packet in a certain formation; Just judge whether its traffic statistics time has surpassed the predefined unit interval of system; If the traffic statistics time has surpassed the unit interval, then note the data flow value in the flow summer of each formation, empty each flow summer then; The zero clearing of the time timer of traffic statistics simultaneously restarts timing; If the traffic statistics time does not surpass the unit interval, then accumulate the flow value of respective queue.Flow value in 8 unit timing statisticses of statistics is asked average flow value as each outbound port in the unit timing statistics continuously
Port [i] _ flow, then each port speed value is:
Wherein i=0,1,2,3,4,5,6,7 is represented port 0, port one, port 2, port 3, port 4, port 5, port 6, port 7 respectively.
TIMEBe the timing statistics counter that is provided with.
Then computing formula is following the poll stand-by period:
.
Wherein,
tBe polymorphic parallel sorting and scheduling startup stand-by period,
DeltaBe outbound port speed,
uBe smoothing factor,
Len_sBe the data packet length of having sent,
Len_nBe next data packet length of sending.
After adopting method of the present invention; A load equalizer can be assigned to the equilibrium of two-channel 2-4 .5G data flow on 8 GBE ports; And make long-time statistical equilibrium degree and temporal equilibrium degree between each GBE port all be superior to 12% (12% is the equilibrium degree index), make load flow more balanced.
Those of ordinary skill in the art will appreciate that embodiment described here is in order to help reader understanding's principle of the present invention, should to be understood that the protection range of inventing is not limited to such special statement and embodiment.Every making according to foregoing description variously possible be equal to replacement or change, and all is considered to belong to the protection range of claim of the present invention.