A system for load balancing of a service chain, comprising a controller, a flow classifier, at least one forwarding device, and multiple value-added service devices, wherein the at least one forwarding device is interconnected, the flow classifier is connected to a policy and charging rules function (PCRF) unit and the forwarding device, and the forwarding device is further connected to the controller and the value-added service devices, wherein:
- the controller is configured to receive a logical service chain definition and a hash quantity, wherein the logical service chain definition comprises information about at least one type of value-added service device that a service chain passes through, the service chain comprises forwarding devices that a service flow should pass through and value-added service devices that the service flow should pass through, the service chain comprises a service chain identifier, the service chain corresponds to the hash quantity, the hash quantity is used to indicate a quantity of subflows that the service flow passing through the service chain is hashed into;
- determine, according to the hash quantity and a quantity of value-added service devices participating in a service, in value-added service devices of a same type, a subflow allocated to each value-added service device participating in the service, in the value-added service devices of the same type;
- generate, according to the logical service chain definition and subflow allocation information, a first flow forwarding table for each forwarding device that the service chain passes through, wherein the first flow forwarding table comprises first matching information and first operation information, wherein the first matching information comprises the service chain identifier and the hashing factors, and the first operation information is used to instruct the forwarding device to send, after receiving a first packet having the service chain identifier and the hashing factor, the first packet to a value-added service device to which a subflow comprising the first packet is allocated;
- and send, to each forwarding device that the service chain passes through, the first flow forwarding table generated for the forwarding device;
- the flow classifier is configured to receive a service chain selection and control policy sent by the PCRF unit;
- hash, according to the hash quantity, the service flow corresponding to the service chain identifier, to obtain multiple subflows, add the service chain identifier and hashing factors to packets of the subflows, wherein different subflows correspond to different hashing factors;
- and send the packets of the subflows after the service chain identifier and the hashing factors are added, to a forwarding device;
- wherein the service chain selection policy comprises a correspondence between the policy context information and the service chain, the service chain selection and control policy comprises a service chain identifier and a correspondence between the service chain and the hash quantity, and the service chain selection and control policy is used to instruct the flow classifier to hash a service flow passing through the service chain, into subflows according to the hash quantity;
- and
- the forwarding device is configured to:
- when receiving a packet to which the service chain identifier and a hashing factor are added and which is sent by the flow classifier, match the packet according to the service chain identifier and hashing factors in first matching information in a first flow forwarding table sent by the controller, then perform an operation according to first operation information, and send a first packet having the service chain identifier and the hashing factor in the first matching information to a value-added service device to which a subflow comprising the first packet is allocated.