The idea: many cables, one logical port

One 1 Gb/s cable between two switches is often not enough, and if it breaks, everything behind it is cut off. So people run several cables. But four plain links between two switches are a loop, and spanning tree turns three of them off. Link aggregation bundles the cables into one logical port, a port-channel (Cisco: EtherChannel; Linux: a bond). Spanning tree, the MAC table and VLAN settings see only the port-channel, and every cable in it carries traffic.

Left: SW-A and SW-B joined by four separate links; spanning tree forwards on L1 and blocks L2, L3 and L4, so only 1 Gb/s is used. Right: the same four links bundled into Po1 with LACP; spanning tree sees one port and all four links forward, 4 Gb/s.
Without LACP spanning tree blocks three links; with Po1 it sees one port and all four carry traffic.

LACP, the Link Aggregation Control Protocol (IEEE 802.1AX, first 802.3ad), is how the two switches agree on which ports belong to the bundle. On the page, SW-A and SW-B are joined by four 1 Gb/s links on ports 1 to 4. Both switches have those ports in channel-group 1 mode active, which gives them key 1. Hosts H1 and H2 sit behind SW-A, a server S behind SW-B, and six flows run from the hosts to S.

What a LACPDU says

Every port that runs LACP sends small frames called LACPDUs to a fixed multicast address that switches never forward. A LACPDU has two halves: what the sender says about itself (the actor) and what it has heard about the other end (the partner). Each half holds a system ID (a 2-byte priority, here 32768, plus the switch MAC), a key, a port number and one byte of state bits:

BitNameSet to 1 means
AActivityactive mode: send LACPDUs on my own (passive ports only answer)
TTimeoutshort timeout: please send to me every 1 s, not every 30 s
GAggregationthis port may be bundled (0 = it can only work alone)
SSynchronizationI have attached this port to the right bundle
CCollectingI accept frames that arrive on this port
DDistributingI send frames on this port
The actor state byte, bit 0 to bit 7: Activity 1, Timeout 0, Aggregation 1, Synchronization 1, Collecting 1, Distributing 1, Defaulted 0, Expired 0. Read as a number it is 0x3D, the state of a bundled port on the slow rate.
A bundled port on the slow rate sends state 0x3D: A, G, S, C and D set.

Bring-up: four rounds

When the cables come up, no port carries data. Each link goes through the same rounds, both ends at once (Demo 1: LACP bring-up):

  1. Each port sends A and G with its own system ID, key and port. It knows nothing about its partner yet.
  2. Now it knows the partner. Ports with the same partner system and matching keys select the same bundle, Po1, attach to it and set S. Each LACPDU echoes what it heard, so each end can check that the other end got it right.
  3. The partner is in sync, so each port starts collecting (C).
  4. The partner is collecting, so each port starts distributing (D). Now the link carries data.

Collecting comes before distributing so that no frame is sent to a port that would throw it away. After bring-up the ports keep sending a LACPDU every 30 s (or 1 s) so that each end knows the other is still there. At least one end must be active; two passive ends wait for each other forever. Cisco's mode on skips LACP entirely and bundles without asking, which is how a wiring mistake turns into a loop.

Keys: who may join

A port joins Po1 only if its key is the bundle's key and its partner is the same switch, with the same key, as the partner of the other members. That stops a cable plugged into the wrong switch, or into a port set up for another bundle, from joining. In Demo 7 someone moves SW-B port 4 to channel-group 2 (key 2). The port leaves Po1 and runs LACP again; SW-A hears partner key 2 instead of 1, so the port never sets S and carries no data. Po1 goes on with three links. Cisco reports such a port as suspended.

Hashing flows onto links

The switch does not spread single frames over the links in turn. Frames of one TCP connection could then overtake each other on links with different queues, and TCP treats reordering as loss. Instead the switch hashes fields of each frame that are the same for the whole flow, and the result picks one link. On the page the hash is (src IP ⊕ dst IP ⊕ src port ⊕ dst port) mod 8. The result is one of 8 buckets, and each bucket points at one member link. F1 is H1 port 50004 to S port 443: (11 ⊕ 20 ⊕ 50004 ⊕ 443) mod 8 = 0, so bucket b0 and link L1, for every frame of F1 (Demo 2).

Six flows go through the hash into buckets b0 to b7, and the buckets point at links L1 to L4. F1 and F4 land on L1 (400 Mb/s), F2 on L2 (200), F3 and F5 on L3 (400), F6 alone on L4. F6 wants 2000 Mb/s but L4 carries only 1000.
Each flow lands on one link, so F6 gets 1000 Mb/s even though Po1 has 4 Gb/s.

Two things follow. First, one flow never gets more than one link: F6, a backup that would take 2000 Mb/s, gets 1000 Mb/s on L4 while Po1 has 4 Gb/s and carries only 2000 Mb/s in all. Four 1 Gb/s links are not one 4 Gb/s link. Second, the spread depends on which fields go into the hash. With MACs only, every flow from H1 gets (0x11 ⊕ 0x20) mod 8 = 1 and every flow from H2 gets 2. L2 carries 600 Mb/s, L3 is full at 1000, and L1 and L4 stay idle (Demo 3). Traffic between two routers is worse still: all of it has the same two MACs. That is why switches let you choose src-dst-ip or src-dst-ip-port.

Flowsrc → dstIP + port hashlinkMAC hashlink
F1H1:50004 → S:4430L11L2
F2H1:50005 → S:4431L21L2
F3H1:50001 → S:806L31L2
F4H2:50007 → S:4434L12L3
F5H2:50004 → S:222L32L3
F6H2:50006 → S:8737L42L3

Each switch hashes only the frames it sends, so the traffic from S back to the hosts can take other links. Picking a bucket by hash is the same trick a load balancer uses to pick a server; making few keys move when the set changes is the topic of consistent hashing.

A link fails

When the cable on L3 is cut, both ends lose light at once and both ports leave Po1 right away. Only the two buckets of L3 move, to the live links in turn: b2 → L1 and b6 → L2. So F5 moves to L1 and F3 to L2, while F1, F2, F4 and F6 stay where they were and their frames stay in order. L1 now carries 600 Mb/s and L2 400 (Demo 4). The page moves only the dead link's buckets, as "resilient hashing" does. Many switches instead rebuild the whole table for three links, which also moves some flows whose link did not fail. Restore the link and LACP runs its four rounds on it before the buckets come back.

A silent link: fast vs slow rate

A cable can fail without going dark. A bad media converter or a broken patch in the middle may pass no frames while both ports still see light. Then only LACP can notice: a port drops its partner when it has heard no LACPDU for 3 × the partner's sending interval. The T bit a port sends chooses that interval for its partner.

RateLACPDU everyTimeoutLost on L3 (F3 + F5 = 400 Mb/s)
slow (T = 0, the default)30 s90 s36000 Mbit = 4500 MB (Demo 5)
fast (T = 1, lacp rate fast)1 s3 s1200 Mbit = 150 MB (Demo 6)

During the timeout the hash still sends F3 and F5 into the dead link. The fast rate costs one small frame per second per port, so it is a common setting on links between switches and servers.

Spanning tree and the bundle

Turn LACP off and the four links are four separate paths between the same two switches: a loop. Spanning tree makes SW-A the root (its bridge ID 32768.001a.0000.000a is lower), gives SW-B port 1 the root port role because all four links cost the same and port 1 has the lowest port ID, and makes ports 2 to 4 alternate ports that discard. All six flows then share L1: 166 Mb/s each (Demo 8). With Po1, spanning tree sees one port with one cost and nothing to block. If one member fails, the port-channel stays up, so spanning tree does not even notice. How spanning tree picks and repairs its tree is on Rapid Spanning Tree.

See also VLANs: a port-channel is usually a trunk that carries many VLANs, set up once on Po1 instead of on each cable. For a spare default gateway instead of a spare cable, see VRRP and HSRP.

See also Flow Monitoring with NetFlow and IPFIX for counting the flows that a port-channel spreads over its links.

What the page leaves out

The Defaulted and Expired state bits (a port that has not heard a partner yet sets Defaulted, so its first LACPDU reads 0x45, not 0x05), passive mode, the full 802.1AX state machines (receive, periodic, selection, mux, churn), the 3-per-second limit on LACPDUs, the port priority and system priority deciding which ports are active when there are more than the bundle allows (hot standby ports), minimum-links settings, Marker PDUs, bundles spread over two switches (MLAG, vPC, stacking), the traffic from SW-B back to the hosts, and exact vendor hash functions (real ones mix more bits, often with CRC). Flow records and NetFlow export are a separate topic.

On the mind map

Open the Networking mind mapNetworkingLayers & links: frames on one local networkLayers & linksIP & routing: packets hop between networksIP & routingCore services: address, name and timeCore servicesTCP, UDP & sockets: end to end between two portsTCP, UDP & socketsHTTP & TLS: what a browser does per requestHTTP & TLSAPIs & push: how apps talk to serversAPIs & pushProxies & edge: boxes in the middle of the pathProxies & edgeContainers: virtual networks from Linux partsContainersReal-time media: voice and video over UDPReal-time mediaSecurity at the edge: filter traffic at the borderSecurity at the edgeProtocol layersProtocol layerseach layer wraps the one above in a headerHub vs switch vs routerHub vs switch vs routerL1 repeats, L2 learns MACs, L3 routes IPIGMP multicastIGMP multicastsnooping sends a group only to membersRapid Spanning TreeRapid Spanning TreeAlternate port takes over at onceLACP Link AggregationOne flow rides one link, never moreVLANsVLANs802.1Q tag splits one switch into LANs802.1X and RADIUS802.1X and RADIUSPort stays closed until Access-AcceptARPARPbroadcast who-has IP, reply with the MACCRCCRCXOR division remainder catches bit errorsInternet ChecksumInternet ChecksumSum + NOT sum = 0xFFFF; blind to swapsWi-Fi CSMA/CAWi-Fi CSMA/CAlisten, random backoff, wait for the ACKBluetooth LE and GATTBluetooth LE and GATTWrite CCCD 0x0001, then values get pushedALOHA and CSMA/CDALOHA and CSMA/CDFrame must last 2τ to hear a collisionLoRaWAN class ALoRaWAN class ASend any time, listen only at RX1/RX2Cellular Reuse and HandoverCellular Reuse and HandoverMargin + timer: no ping-pong, no dropDigital modulation (QAM)Digital modulation (QAM)More bits per symbol needs more SNROpen the Networking mind mapNetworkingframes on one local networkLayers & linksProtocol layersProtocol layerseach layer wraps the one above in a headerHub vs switch vs routerHub vs switch vs routerL1 repeats, L2 learns MACs, L3 routes IPIGMP multicastIGMP multicastsnooping sends a group only to membersRapid Spanning TreeRapid Spanning TreeAlternate port takes over at onceLACP Link AggregationOne flow rides one link, never moreVLANsVLANs802.1Q tag splits one switch into LANs802.1X and RADIUS802.1X and RADIUSPort stays closed until Access-AcceptARPARPbroadcast who-has IP, reply with the MACCRCCRCXOR division remainder catches bit errorsInternet ChecksumInternet ChecksumSum + NOT sum = 0xFFFF; blind to swapsWi-Fi CSMA/CAWi-Fi CSMA/CAlisten, random backoff, wait for the ACKBluetooth LE and GATTBluetooth LE and GATTWrite CCCD 0x0001, then values get pushedALOHA and CSMA/CDALOHA and CSMA/CDFrame must last 2τ to hear a collisionLoRaWAN class ALoRaWAN class ASend any time, listen only at RX1/RX2Cellular Reuse and HandoverCellular Reuse and HandoverMargin + timer: no ping-pong, no dropDigital modulation (QAM)Digital modulation (QAM)More bits per symbol needs more SNR
This page on the Networking mind map · 83 pages in 10 branches · open it to see the whole map and test yourself in recall mode.