Sub topic 3
How frames are spread across member links
This chapter assumes you know Ethernet switching basics (MAC addresses, VLANs, trunks) and TCP/UDP ports. It explains how a port channel decides which member link carries each frame. Hash policy choices come in a later chapter.
The problem: many links, one logical port
A port channel looks like a single interface to the rest of the network. The switch still has to put each outgoing frame on exactly one physical member. It cannot send a frame out of two members, and it must not reorder frames that belong to the same conversation.
TCP and many applications handle reordering poorly. A switch that sent packets of one download alternately over two links could deliver them out of order, forcing retransmissions and slowing the transfer. So switches do not spread individual frames evenly. They spread flows.
Flows and hashing
A flow is a stream of packets that share the same identifying fields, such as source and destination IP address, protocol, and TCP/UDP ports. The switch takes some of those fields, runs them through a hash function, and uses the result to select a member link.
The steps are:
- Read the chosen fields from the frame (for example source and destination IP).
- Combine them into one number with a hash function.
- Take that number modulo the count of active members.
- Send the frame out of the member with that index.
Because the same fields always produce the same hash, every frame of a flow takes the same link and stays in order.
import zlib
def pick_member(src_ip, dst_ip, src_port, dst_port, proto, n_links):
key = f"{src_ip}|{dst_ip}|{src_port}|{dst_port}|{proto}".encode()
return zlib.crc32(key) % n_links
# The same flow always maps to the same member link.
flow = ("10.0.0.5", "10.0.1.9", 50000, 443, "tcp")
print(pick_member(*flow, n_links=2) == pick_member(*flow, n_links=2))This prints True. Real switches use hardware hash functions, not CRC32 over a string, but the principle is the same.
Consequences you can observe
A single flow never exceeds the speed of one member. Two 1 Gbps links in a port channel give 2 Gbps of total capacity, but one file transfer between two hosts still tops out at 1 Gbps.
Balance depends on variety. With many different flows, the hash spreads them roughly evenly. With few flows, or flows that hash to the same value, one link can be busy while another is idle.
Distribution is per direction. Each device chooses the outgoing member for its own transmissions. Switch A's hash policy controls traffic from A to B, and B's policy controls traffic from B to A. The two directions may use different members, and they may use different hash settings.
Which fields are used
Platforms differ in the inputs they can hash. Common choices are source MAC, destination MAC, both MACs, source IP, destination IP, both IPs, and on many platforms Layer 4 ports. The choice matters. If all traffic crosses a router, every frame has the router's MAC as its source or destination. A MAC-based hash then sees very few distinct values and may put everything on one link.
The command show etherchannel load-balance on Cisco IOS style switches shows the active method. The Linux equivalent is the xmit_hash_policy bonding option, shown in the Linux chapter.
Exercise
Two servers are connected by a port channel of four 1 Gbps links. One server runs a single TCP backup stream to the other. What throughput can you expect, and why?
Show answer
About 1 Gbps at most. All frames of one TCP flow share the same hash inputs, so they all select the same member link. The other three links carry none of this flow, even though the bundle has 4 Gbps of total capacity.
Exercise
A port channel carries traffic between many hosts and a single router, and the switch hashes on source and destination MAC only. Why might one member be overloaded?
Show answer
Every frame going to or from the router uses the router's MAC address, so the hash sees few distinct MAC pairs. Many flows can map to the same value and the same member. A hash that includes IP addresses or Layer 4 ports gives more variety.