Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The system architecture and the service scenario described in the embodiment of the present invention are for more clearly illustrating the technical solution of the embodiment of the present invention, and do not form a limitation on the technical solution provided in the embodiment of the present invention, and it can be known by those skilled in the art that the technical solution provided in the embodiment of the present invention is also applicable to similar technical problems along with the evolution of the system architecture and the appearance of a new service scenario.
The above method is described in detail with reference to specific examples. Referring to fig. 1, an embodiment of the present invention is applied to a communication system including: the communication system is applied to an SDN network, so that the embodiment of the application further comprises at least one SDN controller, wherein each SDN controller controls the forwarding of data streams of one or more switches; as shown in fig. 1, at least two data links (a data link one and a data link two) are established between the switches, and the switches are connected to the user network or the service network to implement data streaming between the user network and the service network.
Based on the communication system, an embodiment of the present invention provides a load balancing method for an SDN network, which is shown in fig. 2 and includes the following steps:
101. And the SDN controller calculates data links which can be used by the SDN network according to the link information reported by the switch, wherein the link information comprises link capacity.
Before step 101, a connection is established between an SDN controller and a switch by using an OpenFlow protocol interface, the SDN controller discovers a global SDN network topology by using an LLDP protocol, generates a visualized network topology structure, and calculates a data link usable by the SDN network according to link information reported by the switch based on the network topology structure, where the link information may further include information such as a port state.
102. the SDN controller adds ports corresponding to data links with the same destination address into a load port group, and configures weights of corresponding ports in the load port group according to link capacity of each data link, wherein the weights of the corresponding ports are port number.
In step 102, the SDN controller adds ports corresponding to data links with the same destination address into a port group of a load port, and members in the port group are configurable, and only 8 ports can be included at most, and only one port can be added into one port group. The method comprises the steps of configuring the weight of a corresponding port in a load port group according to the link capacity of a link, and expanding the load port group portGroup into an expanded load port group weightPortGroup based on the weight according to the weight of the port, wherein the number of the ports corresponding to a data link is added according to the ratio of the weight and is discretely added. Such as: one port group includes two ports, the corresponding link capacities are 1M and 2M, respectively, and the corresponding weight values are 1: 2. The details are shown in the following table:
basic load port group: comprises two ports: port1 and Port2, where a data link with a link capacity of 1M corresponds to Port1 and a data link with a link capacity of 2M corresponds to Port 2;
extended load port group WeightPortGroup: corresponding weight of 1:2, comprising three ports
This port combination makes port2 easier to select as an egress port. I.e., links with large link capacities, may have a greater chance of being utilized.
103. The SDN controller obtains a first message of a data flow sent by a switch and obtains header information of the first message.
Specifically, the switch encapsulates a header of a data flow that is not matched to the flow table in a packet _ in message, and sends the packet _ in message to the SDN controller, where the header information includes a source MAC, a destination MAC, a source IP address, a destination IP address, an L4 port, or any combination thereof, for example, the above elements form triplet or quintet information. In addition, before the header information of the first message is acquired, whether the first message of the data flow is a legal message or not can be detected, if so, the header information of the first message is analyzed, and if not, the first message of the data flow is discarded.
104. And the SDN controller performs Hash operation according to the header information to obtain a load balancing factor.
105. And the SDN controller selects a forwarding port according to the load balancing factor and the weight of each port in the load port group.
Specifically, the SDN controller uses, as an alternative forwarding port, a port obtained by calculation according to a load balancing factor and a weight sum of each port in the load port group, and detects an average remaining bandwidth of the alternative forwarding port within a predetermined time period; if the SDN controller determines that the average residual bandwidth is greater than or equal to a set bandwidth threshold, setting the alternative forwarding port as a forwarding port; otherwise, the average residual bandwidth of other ports in the load port group in a preset time length is detected, and the port with the maximum average residual bandwidth in the load port group is set as a forwarding port. For example: the SDN controller detects traffic statistics of the backup port1 in one or more detection periods through a traffic statistics function, and calculates an average remaining bandwidth of the backup port1 within a predetermined time period t. If the average residual bandwidth of the backup port1 is greater than or equal to the bandwidth threshold T, setting the backup port1 as a forwarding port of the data stream, if the average residual bandwidth of the backup port1 is less than the bandwidth threshold T, circularly traversing other ports in the port group, selecting a port with the largest average residual bandwidth at present, then comparing the port with the bandwidth threshold T, if the comparison result is met, setting the port as a forwarding port, and if the traversal is finished or no backup port meeting the condition exists, selecting the backup port with the largest average residual bandwidth at present as the forwarding port.
specifically, the SDN controller performs a modulo operation using a sum of the load balancing factor and the weight, selects a port number in the weightPortGroup according to a result, and uses the port as an alternative port. For example, when hash operation is performed on 5 tuples in the header of a packet to obtain a load balancing factor of one packet is 2, and when the capacities of links corresponding to port1 and port2 are 1M and 4M, respectively, the weight of a port in the weightPortGroup is 1:4, and the port contains 5 ports in total, and the ports are stored according to the port order (not specifically limited), as shown in the following table.
Port1
|
Port2
|
Port2
|
Port2
|
Port2 |
Performing modulus operation according to the sum of the load balancing factor and the weight of each port, wherein the result of selecting the port is as follows: 2mod5 is 2, then port2 is selected based on the memory address of each port in the weightPortGroup. In the embodiment of the present invention, according to the expansion of the port weight, the probability of acquiring the port2 is increased, and a link with a larger bandwidth is easier to use.
106. And the SDN controller generates a forwarding flow table according to the forwarding port and sends the forwarding flow table to the switch.
The SDN controller encapsulates the forwarding flow table in a packet _ out message according to the forwarding port, sends the packet _ out message to the switch, and the switch writes the forwarding flow table translation into the hardware resource and forwards the data flow according to the indicated action of the forwarding flow table.
In the scheme, the SDN controller calculates a data link which can be used by the SDN according to link capacity-containing link information reported by the switch; then adding ports corresponding to data links with the same destination address into a load port group, and configuring the weight of the corresponding port in the load port group according to the link capacity of each data link, wherein the weight of the corresponding port is the port number; acquiring a first message of a data stream sent by a switch, and acquiring header information of the first message; carrying out Hash (Hash) operation according to the head information to obtain a load balancing factor; selecting a forwarding port according to the load balancing factor and the weight of each port in the load port group; finally, a forwarding flow table is generated according to the forwarding port, and the forwarding flow table is sent to the switch, so that the switch can forward the data flow according to the forwarding flow table; because the link capacity of the data link is considered when the forwarding flow table is determined, the link resources of the SDN network can be fully utilized, and the overall performance of the network is improved.
In another embodiment, referring to fig. 3, the method further includes step 107, monitoring, by the SDN controller, states of the ports in the load port group, and when it is determined that the state of any port is down, moving any port out of the load port group, and deleting a forwarding flow table corresponding to any port. Since the forwarding flow table corresponding to any port is deleted, when the switch receives the data flow that cannot be forwarded again, the SDN controller determines that the forwarding port needs to be reselected, and performs the steps after step 102. This avoids the impact of port status on network performance.
in an embodiment as shown in fig. 3, after step 106, a step 108 of monitoring, by the SDN controller, a packet loss rate of the forwarding port is further included; and when the packet loss rate of the forwarding port is determined to be greater than the packet loss rate threshold, reselecting the forwarding port, and deleting the forwarding flow table corresponding to the forwarding port. Packet loss statistics is carried out by monitoring the packet loss rate of the forwarding port within a period of time, so that the phenomenon that routing is recalculated due to burst flow, TCP disconnection is caused, and network performance is reduced is avoided. In step 108, in an exemplary scheme, the reselecting a forwarding port specifically includes: the SDN controller acquires the header information of the discarded message; carrying out Hash (Hash) operation according to the head information to obtain a new load balancing factor; and reselecting the forwarding port according to the new load balancing factor and the weight of each port in the load port group. Wherein the specific implementation of the process is similar to that of step 103-105 and is not described herein again.
An embodiment of the present invention illustrated with reference to fig. 4 provides an SDN controller comprising:
a link management module 41, configured to calculate, according to link information reported by a switch, a data link usable by the SDN network, where the link information includes link capacity;
the link management module 41 is further configured to add ports corresponding to data links with the same destination address into a load port group, and configure weights of corresponding ports in the load port group according to link capacities of the data links, where the weights of the corresponding ports are port numbers;
A message processing module 42, configured to obtain a first message of a data stream sent by a switch, and obtain header information of the first message;
A routing control module 43, configured to perform hash operation according to the header information obtained by the packet processing module 42 to obtain a load balancing factor;
the link management module 41 is further configured to select a forwarding port according to the load balancing factor obtained by the route control module 43 and the weight of each port in the load port group obtained by the link management module 41;
The routing control module 43 is further configured to generate a forwarding flow table according to the forwarding port selected by the link management module 41, and send the forwarding flow table to the switch.
Optionally, as shown in fig. 5, the SDN controller further includes: the link management module 41 is specifically configured to use a port obtained according to the load balancing factor and the weight sum of each port in the load port group as an alternative forwarding port, and detect an average remaining bandwidth of the alternative forwarding port within a predetermined time period; if the average residual bandwidth is determined to be larger than or equal to the set bandwidth threshold, setting the alternative forwarding port as a forwarding port; otherwise, detecting the average residual bandwidth of other ports in the load port group within a preset time length, and setting the port with the maximum average residual bandwidth in the load port group as a forwarding port.
optionally, the link management module 41 is further configured to monitor a state of each port in the load port group, and when it is determined that the state of any port is down, move the port out of the load port group, and the routing control module 43 is further configured to delete a forwarding flow table corresponding to the port.
Optionally, the SDN controller further includes: a traffic statistic module 44, configured to monitor a packet loss rate of the forwarding port; when it is determined that the packet loss rate of the forwarding port is greater than the packet loss rate threshold, the link management module 41 is configured to reselect the forwarding port, and the route control module is further configured to delete the forwarding flow table corresponding to the forwarding port.
in addition, the message processing module 42 is further configured to obtain header information of the discarded message; the routing control module 43 is further configured to perform a hash operation according to the header information of the discarded packet obtained by the packet processing module to obtain a new load balancing factor; the link management module 41 is further configured to reselect a forwarding port according to the new load balancing factor obtained by the routing control module and the weight of each port in the load port group.
In the scheme, the SDN controller calculates a data link which can be used by the SDN according to link capacity-containing link information reported by the switch; then adding ports corresponding to data links with the same destination address into a load port group, and configuring the weight of the corresponding port in the load port group according to the link capacity of each data link, wherein the weight of the corresponding port is the port number; acquiring a first message of a data stream sent by a switch, and acquiring header information of the first message; carrying out Hash operation according to the header information to obtain a load balancing factor; selecting a forwarding port according to the load balancing factor and the weight of each port in the load port group; finally, a forwarding flow table is generated according to the forwarding port, and the forwarding flow table is sent to the switch, so that the switch can forward the data flow according to the forwarding flow table; because the link capacity of the data link is considered when the forwarding flow table is determined, the link resources of the SDN network can be fully utilized, and the overall performance of the network is improved.
Additionally, a computer-readable medium (or media) is also provided, comprising computer-readable instructions that when executed perform the operations of the method in the above-described embodiments.
Additionally, a computer program product is also provided, comprising the above-described computer-readable medium (or media).
It should be understood that, in various embodiments of the present invention, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
in the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus, and method may be implemented in other ways. For example, the above-described device embodiments are merely illustrative, and for example, the division of the units is only one logical functional division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
in addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U disk, a removable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.