Understanding the Algorithm Used to Hash LAG Bundle and Egress Next-Hop ECMP Traffic

 

Juniper Networks EX Series and QFX Series use a hashing algorithm to determine how to forward traffic over a link aggregation group (LAG) bundle or to the next-hop device when equal-cost multipath (ECMP) is enabled.

The hashing algorithm makes hashing decisions based on values in various packet fields, as well as on some internal values like source port ID and source device ID. You can configure some of the fields that are used by the hashing algorithm.

Note

Platform support depends on the Junos OS release in your installation.

This topic contains the following sections:

Understanding the Hashing Algorithm

The hashing algorithm is used to make traffic-forwarding decisions for traffic entering a LAG bundle or for traffic exiting a switch when ECMP is enabled.

For LAG bundles, the hashing algorithm determines how traffic entering a LAG bundle is placed onto the bundle’s member links. The hashing algorithm tries to manage bandwidth by evenly load-balancing all incoming traffic across the member links in the bundle.

For ECMP, the hashing algorithm determines how incoming traffic is forwarded to the next-hop device.

The hashing algorithm makes hashing decisions based on values in various packet fields, as well as on some internal values like source port ID and source device ID. The packet fields used by the hashing algorithm varies by the packet’s EtherType and, in some instances, by the configuration on the switch. The hashing algorithm recognizes the following EtherTypes:

  • IP (IPv4 and IPv6)

  • MPLS

  • MAC-in-MAC

Traffic that is not recognized as belonging to any of these EtherTypes is hashed based on the Layer 2 header. IP and MPLS traffic are also hashed based on the Layer 2 header when a user configures the hash mode as Layer 2 header.

You can configure some fields that are used by the hashing algorithm to make traffic forwarding decisions. You cannot, however, configure how certain values within a header are used by the hashing algorithm.

Note the following points regarding the hashing algorithm:

  • The fields selected for hashing are based on the packet type only. The fields are not based on any other parameters, including forwarding decision (bridged or routed) or egress LAG bundle configuration (Layer 2 or Layer 3).

  • The same fields are used for hashing unicast and multicast packets. Unicast and multicast packets are, however, hashed differently.

  • The same fields are used by the hashing algorithm to hash ECMP and LAG traffic, but the hashing algorithm hashes ECMP and LAG traffic differently. LAG traffic uses a trunk hash while ECMP uses ECMP hashing. Both LAG and ECMP use the same RTAG7 seed but use different offsets of that 128B seed to avoid polarization. The initial config of the HASH function to use the trunk and ECMP offset are set at the PFE Init time. The different hashing ensures that traffic is not polarized when a LAG bundle is part of the ECMP next-hop path.

  • The same fields are used for hashing regardless of whether the switch is or is not participating in a mixed or non-mixed Virtual Chassis or Virtual Chassis Fabric (VCF).

The fields used for hashing by each EtherType as well as the fields used by the Layer 2 header are discussed in the following sections.

IP (IPv4 and IPv6)

Payload fields in IPv4 and IPv6 packets are used by the hashing algorithm when IPv4 or IPv6 packets need to be placed onto a member link in a LAG bundle or sent to the next-hop device when ECMP is enabled.

The hash mode is set to Layer 2 payload field, by default. IPv4 and IPv6 payload fields are used for hashing when the hash mode is set to Layer 2 payload.

If the hash mode is configured to Layer 2 header, IPv4, IPv6, and MPLS packets are hashed using the Layer 2 header fields. If you want incoming IPv4, IPv6, and MPLS packets hashed by the source MAC address, destination MAC address, or EtherType fields, you must set the hash mode to Layer 2 header.

Table 1 displays the IPv4 and IPv6 payload fields that are used by the hashing algorithm, by default.

  • ✓—Field is used by the hashing algorithm, by default.

  • Χ—Field is not used by the hashing algorithm, by default.

  • (configurable)—Field can be configured to be used or not used by the hashing algorithm.

Table 1: IPv4 and IPv6 Hashing Fields

Fields

EX4300

QFX5100

QFX5110

QFX5200

 

LAG

ECMP

LAG

ECMP

LAG

ECMP

LAG

ECMP

Source MAC

X

Χ

Χ

Χ

Χ

Χ

Χ

X

Destination MAC

Χ

Χ

Χ

Χ

Χ

Χ

Χ

Χ

EtherType

Χ

Χ

Χ

Χ

Χ

Χ

Χ

Χ

VLAN ID

Χ

(configurable)

Χ

(configurable)

Χ

(configurable)

Χ

(configurable)

Χ

(configurable)

Χ

(configurable)

Χ

(configurable)

Χ

(configurable)

Source IP or IPv6

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

Destination IP or IPv6

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

Protocol (IPv4 only)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

Next header (IPv6 only)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

Layer 4 Source Port

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

Layer 4 Destination Port

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

(configurable)

IPv6 Flow label (IPv6 only)

Χ

Χ

Χ

Χ

Χ

Χ

Χ

Χ

MPLS

The hashing algorithm hashes MPLS packets using the source IP, destination IP, MPLS label 0, MPLS label 1, and MPLS label 2 fields. On the QFX5110 and QFX5200 switches, , LSR routers also support ECMP. ECMP uses these fields for hashing on an LSR router:

  • Layer 3 VPN: MPLS Labels (top 3 labels), source IP, destination IP, and ingress port ID

  • Layer 2 Circuit: MPLS Labels (top 3 labels) and ingress port ID

Table 2 displays the MPLS payload fields that are used by the hashing algorithm, by default:

  • ✓—Field is used by the hashing algorithm, by default.

  • Χ—Field is not used by the hashing algorithm, by default.

The fields used by the hashing algorithm for MPLS packet hashing are not user-configurable.

The source IP and destination IP fields are not always used for hashing. For non-terminated MPLS packets, the payload is checked if the bottom of stack (BoS) flag is seen in the packet. If the payload is IPv4 or IPv6, then the IP source address and IP destination address fields are used for hashing along with the MPLS labels. If the BoS flag is not seen in the packet, only the MPLS labels are used for hashing.

Table 2: MPLS Hashing Fields

Field

EX4300

QFX5100

QFX5110

QFX5200

Source MAC

Χ

Χ

Χ

Χ

Destination MAC

Χ

Χ

Χ

Χ

EtherType

Χ

Χ

Χ

Χ

VLAN ID

Χ

Χ

Χ

Χ

Source IP

Destination IP

Protocol (for IPv4 packets)

Χ

Χ

Χ

Χ

Next header (for IPv6 packets)

Χ

Χ

Χ

Χ

Layer 4 Source Port

Χ

Χ

Χ

Χ

Layer 4 Destination Port

Χ

Χ

Χ

Χ

IPv6 Flow lab

Χ

Χ

Χ

Χ

MPLS label 0

MPLS label 1

MPLS label 2

Ingress Port ID

X

X

X

(LSR and L2Circuit)

(LSR and L2Circuit)

MAC-in-MAC Packet Hashing

Packets using the MAC-in-MAC EtherType are hashed by the hashing algorithm using the Layer 2 payload source MAC, Layer 2 payload destination MAC, and Layer 2 payload EtherType fields. See Table 3.

Hashing using the fields in the MAC-in-MAC EtherType packet is first supported on EX4300 switches in Release 13.2X51-D20. Hashing using the fields in the MAC-in-MAC EtherType is not supported on earlier releases.

The fields used by the hashing algorithm for MAC-in-MAC hashing are not user-configurable.

  • ✓—Field is used by the hashing algorithm, by default.

  • Χ—Field is not used by the hashing algorithm, by default.

Table 3: MAC-in-MAC Hashing Fields

Field

EX4300

QFX5100

QFX5110

QFX5200

Layer 2 Payload Source MAC

Layer 2 Payload Destination MAC

Layer 2 Payload EtherType

Layer 2 Payload Outer VLAN

Χ

Χ

Χ

Χ

Layer 2 Header Hashing

Layer 2 header fields are used by the hashing algorithm when a packet’s EtherType is not recognized as IP (IPv4 or IPv6), MPLS, or MAC-in-MAC. The Layer 2 header fields are also used for hashing IPv4, IPv6, and MPLS traffic instead of the payload fields when the hash mode is set to Layer 2 header.

  • ✓—Field is used by the hashing algorithm, by default.

  • Χ—Field is not used by the hashing algorithm, by default.

  • (configurable)—Field can be configured to be used or not used by the hashing algorithm.

Table 4: Layer 2 Header Hashing Fields

Field

EX4300

QFX5100

QFX5110

QFX5200

Source MAC

(configurable)

(configurable)

(configurable)

(configurable)

Destination MAC

(configurable)

(configurable)

(configurable)

(configurable)

EtherType

(configurable)

(configurable)

(configurable)

(configurable)

VLAN ID

Χ

(configurable)

Χ

(configurable)

(configurable)

(configurable)