Understanding Eth-Trunk Load Balancing of S Series Switches
Introduction
This document describes Eth-Trunk forwarding fundamentals, load balancing mode, and how to configure Eth-Trunk load balancing.
Prerequisites
This document uses S5720HI as an example. There may be differences in the implementation of different switch models and versions. For details, see the corresponding product documentation.
Context
Because an Eth-Trunk between two devices consists of multiple physical links bundled together, an Eth-Trunk may transmit data frames of the same data flow over different physical links. A potential problem arises in that the second data frame may arrive at the remote device earlier than the first data frame, resulting in out-of-order packets.
To prevent out-of-order packets, Eth-Trunk uses flow-based load balancing. This mechanism uses the hash algorithm to calculate the address in a data frame and generate a hash key based on which the system searches for the outbound interface in the Eth-Trunk forwarding table. Each MAC or IP address corresponds to a hash key, so the system uses different outbound interfaces to forward data. This mechanism ensures that frames of the same data flow are forwarded on the same physical link and implements load balancing of data flows. Flow-based load balancing ensures the correct sequence of data transmission, but cannot ensure efficient bandwidth usage.
Forwarding Fundamentals
In Figure 1, an Eth-Trunk is located at the data link layer, between the MAC address and LLC sub-layers.
The Eth-Trunk module maintains a forwarding table that consists of the following entries:
- HASH-KEY value
The HASH-KEY value is calculated through the hash algorithm based on the MAC address or IP address in a data packet.
- Interface number
Eth-Trunk forwarding entries are related to the number of member interfaces in an Eth-Trunk. Different HASH-KEY values map to different outbound interfaces.
For example, an Eth-Trunk supports a maximum of eight member interfaces. If physical interfaces 1, 2, 3, and 4 are bundled into an Eth-Trunk, the Eth-Trunk forwarding table contains four entries, as shown in Figure 2. In the Eth-Trunk forwarding table, hash keys are 0, 1, 2, 3, 4, 5, 6, and 7, and the corresponding outbound interface numbers are 1, 2, 3, 4, 1, 2, 3, and 4. Therefore, optimal load balancing can be implemented only when two, four, or eight interfaces are added to an Eth-Trunk.
The Eth-Trunk module forwards a packet according to the Eth-Trunk forwarding table:
- The Eth-Trunk module receives a packet from the MAC sub-layer, and then extracts its source MAC address/IP address or destination MAC address/IP address.
- The Eth-Trunk module calculates the HASH-KEY value using the hash algorithm.
- Using the HASH-KEY value, the Eth-Trunk module searches the Eth-Trunk forwarding table for the interface number, and then sends the packet from the corresponding interface.
Load Balancing Modes of an Eth-Trunk
You can set the load balancing mode based on traffic models. When a field of traffic changes frequently, you can set the load balancing mode based on this field to ensure that the traffic is load balanced evenly. For example, if IP addresses in packets change frequently, use the load balancing mode based on the destination IP address, source IP address, or both source and destination IP addresses. If MAC addresses in packets change frequently and IP addresses are fixed, use the load balancing mode based on the destination MAC address, source MAC address, or both source and destination MAC addresses.
According to your network requirements, you can configure load balancing based on the following information:
- Source MAC address
- Destination MAC address
- Source and destination MAC addresses
- Source IP address
- Destination IP address
- Source and destination IP addresses
- VLAN IDs and source physical port numbers for Layer 2, IPv4, IPv6, and MPLS packets in enhanced load balancing mode
For example, DeviceA has two TCP packet flows. In one TCP packet flow, the source IP address is 192.168.1.1 (MAC address: a-a-a; source port number: 50), and the destination IP address is 172.16.1.1 (MAC address: b-b-b; destination port number: 2000). In another TCP packet flow, the source IP address is 192.168.1.1 (MAC address: a-a-a; source port number: 60), and the destination IP address is 10.1.1.1 (MAC address: c-c-c; destination port number: 2000). If load balancing based on the source MAC address is configured on DeviceA, only one outbound interface is available for sending packets out. On the other hand, if load balancing based on the destination IP address is configured on DeviceA, packets destined for different destination IP addresses are sent out through different outbound interfaces.
When configuring a load balancing mode, pay attention to the following points:
- The load balancing mode takes effect only on traffic leaving outbound interfaces. If traffic arriving at inbound interfaces is uneven, change the load balancing mode of the uplink outbound interface.
- If possible, ensure data flows are load balanced among all active links. If data flows are transmitted over one link, traffic congestion may occur, affecting services.
For example, when data packets have only one destination MAC address and one destination IP address, perform load balancing based on the source MAC address and source IP address. If load balancing based on the destination MAC address and destination IP address is used, traffic is transmitted over one link, causing congestion.
If traffic is unevenly load balanced after the configuration is complete, rectify the fault according to How Do I Adjust Eth-Trunk Configurations on S Series Switches When Eth-Trunk Load Balancing Is Uneven.
Configuring a Load Balancing Mode for Link Aggregation
You can configure a common or enhanced load balancing mode. Configure either of them as required.
Configure a common load balancing mode.
- Run the system-view command to enter the system view.
- Run the interface eth-trunk trunk-id command to enter the Eth-Trunk interface view.
- Run the load-balance { dst-ip | dst-mac | src-ip | src-mac | src-dst-ip | src-dst-mac } command to set a load balancing mode of the Eth-Trunk.
By default, the load balancing mode is src-dst-ip.
The following example shows how to configure load balancing based on source and destination MAC addresses on Eth-Trunk 1, and check whether the configuration is successful.
<HUAWEI> system-view [HUAWEI] interface eth-trunk 1 [HUAWEI-Eth-Trunk1] load-balance src-dst-mac [HUAWEI-Eth-Trunk1] quit [HUAWEI] display eth-trunk 1 load-balance Eth-Trunk1's load-balance information: Load-balance Configuration: SA-XOR-DA Load-balance options used per-protocol: L2 : Source XOR Destination MAC address, Vlan ID, Ethertype, Ingress-port IPv4: Source XOR Destination MAC address, Vlan ID, Ethertype, Ingress-port IPv6: Source XOR Destination MAC address, Vlan ID, Ethertype, Ingress-port MPLS: Source XOR Destination MAC address, Vlan ID, Ethertype, Ingress-port
The preceding information shows that the Load-balance Configuration field is displayed as SA-XOR-DA, indicating that the load balancing mode of Eth-Trunk 1 is based on source and destination MAC addresses.
Item |
Description |
---|---|
Load-balance Configuration |
Configured load balancing mode. The options are as follows:
|
Load-balance options used per-protocol |
Load balancing parameters of different types of packets. |
Configure an enhanced load balancing mode.
- Run the system-view command to enter the system view.
- Run the load-balance-profile profile-name command to create a load balancing profile and enter the profile view. Only one load balancing profile can be created.
- You can configure load balancing modes for Layer 2 packets, IPv4 packets, IPv6 packets, and MPLS packets respectively.
- Run the l2 field [ dmac | l2-protocol | smac | sport | vlan ] * command to set a load balancing mode of Layer 2 packets. By default, load balancing of Layer 2 packets is based on the source MAC address (smac) and destination MAC address (dmac).
- Run the ipv4 field [ dip | l4-dport | l4-sport | protocol | sip | sport | vlan ] * command to set a load balancing mode for IPv4 packets in a specified load balancing profile. By default, load balancing of IPv4 packets is based on the source IP address (sip) and destination IP address (dip).
- Run the ipv6 field [ dip | l4-dport | l4-sport | protocol | sip | sport | vlan ] * command to set a load balancing mode for IPv6 packets in a specified load balancing profile. By default, load balancing of IPv6 packets is based on the source IP address (sip) and destination IP address (dip).
- Run the mpls field [ 2nd-label | 3rd-label | dip | dmac | l4-dport | l4-sport | protocol | sip | smac | sport | top-label | vlan ] * command to set a load balancing mode of MPLS packets in a specified load balancing profile. By default, load balancing of MPLS packets is based on the two outer labels (top-label and 2nd-label) of each packet.
- Run the quit command to return to the system view.
- Run the interface eth-trunk trunk-id command to enter the Eth-Trunk interface view.
- Run the load-balance enhanced profile profile-name command to apply the load balancing profile.
The following example shows how to create a load balancing profile a, set the load balancing mode of IPv6 packets to sip and protocol, and apply the load balancing profile to Eth-Trunk 1. Then check whether the configuration is successful.
<HUAWEI> system-view [HUAWEI] load-balance-profile a [HUAWEI-load-balance-profile-a] ipv6 field sip protocol [HUAWEI-load-balance-profile-a] quit [HUAWEI] interface eth-trunk 1 [HUAWEI-Eth-Trunk1] load-balance enhanced profile a [HUAWEI-Eth-Trunk1] quit [HUAWEI] display eth-trunk 1 load-balance Eth-Trunk1's load-balance information: Load-balance Configuration: ENHANCED Load-balance enhanced profile: a Load-balance options used per-protocol: L2 : Source XOR Destination MAC address IPv4: Source XOR Destination IP address IPv6: Source IP address, IP protocol MPLS: Top XOR Second label
According to the preceding information, the Load-balance Configuration field is displayed as ENHANCED, indicating that the enhanced load balancing mode is set on Eth-Trunk 1. If the IPv6 field in Load-balance options used per-protocol is displayed as Source IP address, IP protocol, IPv6 packets are load balanced based on the source IP address and protocol.