Sub topic 7
Flooding when the destination is unknown or non-unicast
This chapter assumes you know the Ethernet frame fields (destination MAC, source MAC, EtherType). It also assumes you know that a switch learns source addresses into a MAC table, as covered in earlier chapters. Here we look at what the switch does when the table cannot give it a single output port.
When a switch floods
Flooding means sending a copy of the frame out of every port in the same VLAN, except the port the frame arrived on. A switch floods in three cases:
- Unknown unicast. The destination is a unicast address, but no table entry exists for it. The entry may never have been learned, or it may have aged out.
- Broadcast. The destination is
ff:ff:ff:ff:ff:ff. Every host on the VLAN is meant to receive it. - Multicast. The destination has the group bit set (the lowest bit of the first octet). A switch never learns a group address as a source, so it has no entry for it. By default it floods these frames.
The switch makes this decision from the destination address alone. It does not look at the frame's contents.
A small model
The function below captures the forwarding rule. It leaves out aging and learning so that the flooding cases stand out.
def is_group(mac):
# Lowest bit of the first octet marks broadcast and multicast.
return int(mac.split(':')[0], 16) & 1 == 1
def decide(table, ports, in_port, dst):
"""table maps mac -> port. Return the ports the frame leaves on."""
if is_group(dst) or dst not in table:
return sorted(ports - {in_port}) # flood
out_port = table[dst]
return [] if out_port == in_port else [out_port]
ports = {1, 2, 3}
table = {'00:00:00:00:00:0b': 2}
print(decide(table, ports, 1, '00:00:00:00:00:0b')) # known: [2]
print(decide(table, ports, 1, '00:00:00:00:00:0c')) # unknown unicast: [2, 3]
print(decide(table, ports, 1, 'ff:ff:ff:ff:ff:ff')) # broadcast: [2, 3]
print(decide(table, ports, 1, '01:00:5e:00:00:05')) # multicast: [2, 3]The ingress port is never in the output list. Sending a frame back where it came from would only create a duplicate.
Why flooding is safe and why it is costly
Flooding is safe because the switch has no wrong information to act on. If the destination host exists, it receives a copy and accepts the frame. Every other host sees a frame addressed to someone else and discards it at its network card.
Flooding is also how the table fills in. Suppose host A sends to host B, and B is unknown. The switch floods the frame and B receives it. When B replies, the switch learns B's port from the reply's source address. After that, traffic between A and B is forwarded to a single port. Unknown unicast flooding is therefore usually short-lived.
Flooding costs bandwidth on every link and wastes CPU on every host that receives an unwanted frame. Two situations make it a problem:
- Persistent unknown unicast. A host that only receives and never sends never gets learned, so frames for it flood continuously. Entries that age out before the next frame arrives have the same effect.
- Broadcast volume. ARP requests and similar protocols are broadcasts by design. A large VLAN carries all of them to every host.
Check your understanding
Exercise
Switch port 1 receives a frame with destination 01:00:5e:00:00:05. The table has entries for ports 2 and 3 only. Which ports does the frame leave on, and why?
Show answer
Ports 2 and 3 (every other port in the VLAN). The first octet 0x01 has its lowest bit set, so this is a multicast address. The switch never learns group addresses, so it has no entry and floods the frame. It does not send the frame back out port 1.