Skip to content

Chapter 16: The GPU Compute Network -- Packet Anatomy End to End · Part 5 of 12

Act 4 -- The first hop: leaf switch processing

The frame arrives at the leaf switch on a front-panel port. In a BasePOD, the leaf's front-panel ports connect to DGX nodes; its uplink ports connect to spines. The leaf switch performs the first routing decision.

Leaf switch processing -- L2 access -> L3 route -> ECMP -> MAC rewrite
Toggle ECMP hash mode to see how BTH QPair hashing changes spine selection.
1. Frame arrives on swp1
Server-facing L2 access port. Switch reads dst MAC.
dst MAC = aa:bb:cc:11:22:33 = my own gateway MAC -> this is a routed packet, not switched
2. IP route lookup
Strip Ethernet, look up dst IP 10.2.1.1 in route table.
Route: 10.2.1.0/24 via 10.0.0.X (spine loopbacks), 4 ECMP paths. TTL decremented.
3. ECMP hash + MAC rewrite
Hash selects uplink. New Ethernet header written.
New src MAC = swp36 port MAC. New dst MAC = selected spine's port MAC. Old MACs gone.
ECMP hash configuration
Hash input fields
src_ip: 10.1.1.1
dst_ip: 10.2.1.1
proto: UDP(17)
src_port: 49512
dst_port: 4791
BTH.DstQPN: 0x000042 <- extra entropy
Hash: CRC32(10.1.1.1 | 10.2.1.1 | 17 | 49512 | 4791 | 0x42) = 0x3F91 -> mod 4 = Spine 0
Two AllReduce QPs between same GPU pair: QPN 0x42 -> Spine 1, QPN 0x43 -> Spine 3 -> perfect distribution
Enable: nv set system forwarding ecmp-hash roce enable

L2 on the server-facing port, L3 on the uplinks

In a pure-routed Clos AI fabric (the BasePOD reference design), the server-facing ports (swp1-swp32 on a Spectrum-X leaf) are L2 access ports. The uplink ports (swp33-swp64, connecting to spines) are L3 routed ports with no VLAN, no bridging. In an EVPN-VXLAN fabric the server-facing ports are also access ports but carry VLAN tags that identify tenants; the routing happens at the VXLAN overlay level. For this chapter, the pure-routed model is assumed throughout.

When the frame from the ConnectX-7 arrives on swp1:

  1. The switch reads the destination MAC. If it matches a locally-connected device's MAC -- stop, deliver locally (intra-leaf traffic).
  2. If the destination MAC is the switch's own MAC (i.e., the gateway MAC that the ConnectX-7 ARPed for), this is a routed packet. The switch strips the Ethernet header and performs an IP route lookup.
  3. IP route lookup on destination IP (e.g., 10.2.1.1 -- the remote GPU's HCA IP): result is next-hop = one of the spine switches, via one of the uplink ports.
  4. ECMP hash computation to select which uplink.

The ECMP hash: what fields, why BTH matters

Standard ECMP hashes the 5-tuple: src IP, dst IP, IP protocol, src UDP port, dst UDP port. This produces reasonable entropy for general traffic. But RoCEv2 AllReduce traffic has a problem: all packets between the same GPU pair use the same src IP, dst IP, and dst UDP port (4791). The only variation is the src UDP port -- which the ConnectX-7 generates from a hash of the QPN, and which is often similar across flows between the same pair.

The fix is to include the RoCEv2 BTH QPair number in the hash. Spectrum-X switches can be configured to parse UDP payload for the BTH header and include the Destination QPN field (bytes 5-7 of the BTH, right after the opcode and partition key). This is configured with:

nv set system forwarding ecmp-hash roce enable

With BTH QPair hashing enabled, two simultaneous AllReduce operations between the same GPU pair on different QPs will hash to different spines -- perfect entropy for AI traffic.

ARP: where it runs and what it produces

When HCA0 on Node A first comes up, it ARPs for its default gateway (the leaf switch's IP on the server-facing subnet). The leaf switch answers with its own MAC. HCA0 caches this: 10.1.0.1 is-at aa:bb:cc:dd:ee:ff. All subsequent packets from HCA0 use aa:bb:cc:dd:ee:ff as the Ethernet destination -- regardless of the IP destination. This is standard L3 routing. The leaf switch's ARP table, conversely, holds 10.1.1.1 is-at 94:6d:ae:xx:xx:xx (the ConnectX-7's IP mapped to its MAC). The leaf uses this when forwarding return traffic back to the GPU.

Frame rewrite at the leaf

After the ECMP hash selects uplink swp36 (connecting to SpineC), the leaf rewrites the Ethernet header:

Before (arriving from GPU):
  Src MAC: 94:6d:ae:aa:bb:cc  (ConnectX-7 on Node A)
  Dst MAC: aa:bb:cc:11:22:33  (Leaf switch swp1 gateway MAC)

After (departing toward SpineC):
  Src MAC: aa:bb:cc:44:55:66  (Leaf switch swp36 port MAC)
  Dst MAC: aa:bb:cc:77:88:99  (SpineC swp12 port MAC, learned from BGP next-hop ARP)

The IP header is unchanged. The TTL is decremented from 64 to 63.

Capture B shows the frame as it arrives on swp1 (before the L3 lookup). Capture C shows the same frame as it leaves on swp36 (after the MAC rewrite and TTL decrement). Compare the two: the IP header and BTH-carrying payload are byte-for-byte identical; only the Ethernet header has changed.

Capture B -- Leaf1 ingress (swp1, server-facing port)
Leaf1 mirror port -- server-facing side of swp1
Frame arriving at the first leaf switch. Identical to Capture A -- no changes have been made yet. The leaf switch is about to perform an IP route lookup and MAC rewrite.
CHANGED
PRESERVED
KEY FIELD
Wireshark -- Capture B
>Destinationaa:bb:cc:11:22:33aa bb cc 11 22 33PRESERVED
Source94:6d:ae:aa:bb:cc94 6d ae aa bb ccPRESERVED
EtherType0x0800 (IPv4)08 00
Capture C -- Leaf1 egress (swp36, spine-facing uplink)
Leaf1 mirror port -- spine-facing side of swp36 (uplink to SpineC)
Same frame after Leaf1's L3 lookup and MAC rewrite. The ECMP hash selected uplink swp36 -> SpineC. The Ethernet header has been completely rewritten. The IP header has TTL decremented by 1. Everything above IP is unchanged.
CHANGED
PRESERVED
KEY FIELD
Wireshark -- Capture C
>Destinationaa:bb:cc:77:88:99aa bb cc 77 88 99CHANGED
>Sourceaa:bb:cc:44:55:66aa bb cc 44 55 66CHANGED
EtherType0x0800 (IPv4) -- unchanged

What the leaf's routing table looks like under BGP vs IS-IS

Under eBGP (the standard):

Destination: 10.2.1.1/32 (remote GPU's HCA IP)
  Via: 10.0.0.3 (SpineC loopback, BGP next-hop)
  Protocol: BGP, distance 20
  ECMP: 4 paths (via SpineA, SpineB, SpineC, SpineD)

Under IS-IS Flex Algo 128 (low-latency plane):

Destination: 10.2.1.1/32
  Via: SpineA and SpineB only (SpineC excluded by delay constraint)
  Protocol: IS-IS, Flex Algo 128
  Metric: delay-based (SpineC excluded: delay 8us > 5us threshold)

The packet itself does not change based on protocol -- the routing table lookup produces a next-hop either way. The difference is which spines are eligible. Under Flex Algo 128, the ECMP hash runs over fewer paths, potentially producing different distribution, but the frame that leaves the leaf is identical format regardless of which protocol chose the next-hop.