Sub topic 2
Unicast, broadcast and multicast destinations
This chapter assumes you know the three Ethernet header fields (destination MAC, source MAC, EtherType) and the difference between a MAC address and an IP address. It covers how a switch classifies the destination address of each frame. That classification decides whether the switch consults its MAC address table at all.
The group bit in the first octet
A MAC address is 48 bits, written as six octets. The switch looks at the least significant bit of the first octet. This is the Individual/Group (I/G) bit.
- I/G = 0: the address names one interface. This is a unicast address.
- I/G = 1: the address names a group of interfaces. This is a multicast address, and broadcast is the special case where every bit is 1.
The next bit, the Universal/Local (U/L) bit, does not change forwarding. It records whether the address was assigned by a manufacturer (0) or set locally (1). Virtual machines, containers, and some privacy features create locally administered addresses, and a switch treats them like any other unicast address.
| Type | Recognizing it | Example | I/G bit |
|---|---|---|---|
| Unicast | First octet is even | `00:1a:2b:3c:4d:5e` | 0 |
| Broadcast | All 48 bits set | `ff:ff:ff:ff:ff:ff` | 1 |
| Multicast, IPv4 | Prefix `01:00:5e` | `01:00:5e:00:00:fb` | 1 |
| Multicast, IPv6 | Prefix `33:33` | `33:33:00:00:00:01` | 1 |
| Bridge control | `01:80:c2:00:00:00` to `0f` | `01:80:c2:00:00:00` | 1 |
Test the bit on the first octet, not the last. 0x01 is odd, so 01:00:5e:... is a group address. 0x02 is even, so 02:42:ac:11:00:02 is still unicast, even though it is locally administered.
Group addresses are destinations only
A group address identifies a set of receivers. A frame is always sent by one interface, so a valid source address is always unicast. The switch relies on this in the learning step. It never records a group address as a source, because a group address does not belong behind any single port.
If a frame arrives with a group address as its source, a conforming switch should not learn from it. The sample switch in this tutorial enforces this with if not is_group(src).
What the switch does with each type
The destination type selects the path through the switch.
Unicast. The switch looks up the destination in its table. A hit on another port gives a single output port. A hit on the ingress port means the frame is filtered. A miss floods the frame to every other port in the VLAN. This is called unknown unicast flooding.
Broadcast. ff:ff:ff:ff:ff:ff is never stored in the table, so there is nothing to look up. The switch always floods the frame out of every port in the VLAN except the ingress port. ARP requests, DHCP discovers, and many other discovery protocols rely on this behavior. A broadcast domain is the set of ports that receive each other's broadcasts. Without VLANs, the whole switch is one broadcast domain. Hubs and switches differ here: a switch separates collision domains per port, but it does not separate broadcast domains.
Multicast. A multicast address also never appears as a source, so it is not in the table either. By default, a switch treats multicast like broadcast and floods it within the VLAN. Every host on the VLAN then receives the frame at the link layer, even hosts that did not join the group. The network card usually discards unwanted multicast in hardware, but the traffic still consumes link bandwidth on every port.
Multicast address mapping
IP multicast addresses map into Ethernet multicast addresses algorithmically, with no ARP involved.
- IPv4: the prefix
01:00:5e, then a zero bit, then the low 23 bits of the group address. Only 23 of the 28 variable bits of an IPv4 group address fit, so 32 different groups share each MAC address. For example,224.1.1.1and239.129.1.1both map to01:00:5e:01:01:01. - IPv6: the prefix
33:33, then the low 32 bits of the group address. For example,ff02::1(all nodes) maps to33:33:00:00:00:01.
Because of the 32:1 overlap, a host that joined one group may also receive frames meant for another that maps to the same MAC. The IP layer discards the extras.
Limiting multicast flooding
Many switches can avoid flooding multicast to uninterested ports. IGMP snooping (IPv4) and MLD snooping (IPv6) make the switch watch membership reports between hosts and routers. It then builds multicast table entries that list only the ports with interested receivers.
These entries are not learned from source addresses. They come from the control messages. Snooping is a separate feature from the learning process in this tutorial, and it is often disabled by default or applies only to specific VLANs. Some multicast ranges, such as IPv4 224.0.0.x link-local groups, are flooded regardless, because routing protocols and neighbor discovery depend on them.
Reserved bridge addresses
The range 01:80:c2:00:00:00 to 01:80:c2:00:00:0f is reserved for protocols that talk to the next bridge on the link. A standards-conforming bridge does not forward these frames. It either processes them itself or discards them.
01:80:c2:00:00:00: Spanning Tree Protocol BPDUs.01:80:c2:00:00:01: Ethernet PAUSE flow control.01:80:c2:00:00:02: Link Aggregation Control Protocol (LACP).
This is why a spanning tree message from one switch reaches only its direct neighbor and is never relayed across the network.
Classifying addresses in code
This program classifies an address by the I/G and U/L bits. It also computes the multicast MAC for an IPv4 group.
def parse(mac):
octets = mac.lower().split(':')
if len(octets) != 6 or any(len(o) != 2 for o in octets):
raise ValueError(f'not a MAC address: {mac!r}')
return [int(o, 16) for o in octets]
def classify(mac):
b = parse(mac)
if all(x == 0xFF for x in b):
kind = 'broadcast'
elif b[0] & 1:
kind = 'multicast'
else:
kind = 'unicast'
admin = 'locally administered' if b[0] & 2 else 'universally administered'
reserved = b[:5] == [0x01, 0x80, 0xC2, 0x00, 0x00] and b[5] <= 0x0F
return kind, admin, reserved
def ipv4_group_to_mac(ip):
p = [int(x) for x in ip.split('.')]
if len(p) != 4 or not 224 <= p[0] <= 239:
raise ValueError(f'not an IPv4 multicast address: {ip}')
low23 = ((p[1] & 0x7F) << 16) | (p[2] << 8) | p[3]
return '01:00:5e:%02x:%02x:%02x' % (low23 >> 16, (low23 >> 8) & 0xFF, low23 & 0xFF)
for m in ['00:1a:2b:3c:4d:5e', '02:42:ac:11:00:02', 'ff:ff:ff:ff:ff:ff',
'01:00:5e:00:00:fb', '33:33:00:00:00:01', '01:80:c2:00:00:00']:
print(m, classify(m))
print(ipv4_group_to_mac('224.0.0.251'))
print(ipv4_group_to_mac('224.1.1.1'), ipv4_group_to_mac('239.129.1.1'))Running it prints:
00:1a:2b:3c:4d:5e ('unicast', 'universally administered', False)
02:42:ac:11:00:02 ('unicast', 'locally administered', False)
ff:ff:ff:ff:ff:ff ('broadcast', 'locally administered', False)
01:00:5e:00:00:fb ('multicast', 'universally administered', False)
33:33:00:00:00:01 ('multicast', 'locally administered', False)
01:80:c2:00:00:00 ('multicast', 'universally administered', True)
01:00:5e:00:00:fb
01:00:5e:01:01:01 01:00:5e:01:01:01The broadcast line reports "locally administered" only because all bits, including U/L, are 1. The U/L bit has no meaning for group addresses in forwarding. The last two lines show the collision between 224.1.1.1 and 239.129.1.1.
Common errors
- Checking the wrong end of the address. The group bit is in the first octet, not the last.
- Expecting broadcast or multicast addresses in the MAC table. They are not learned, so
show mac address-tablenever listsffff.ffff.ffffas a dynamic entry. - Treating "flooded" as "broadcast". Unknown unicast frames are flooded, but they are not broadcasts. Only the destination
ff:ff:ff:ff:ff:ffis a broadcast, and hosts do not process flooded unicast not addressed to them. - Assuming a switch isolates multicast by default. Without snooping, a high-rate multicast stream such as video reaches every port in the VLAN.
- Assuming the mapped multicast MAC uniquely identifies an IPv4 group. Several groups share each address.
Exercise
A frame arrives on port 3 with destination 01:00:5e:7f:00:01 and source 00:00:00:00:00:0c. IGMP snooping is off. Which bit tells you the frame is a group frame, what does the switch do with the destination, and does the switch record anything from this frame?
Show answer
The least significant bit of the first octet (0x01) is 1, so it is a group address. It is not broadcast, because not all bits are set, so it is multicast. With snooping off, the switch skips the table lookup and floods the frame out of every port in the VLAN except port 3. The source 00:00:00:00:00:0c is unicast (first octet 0x00, I/G bit 0), so the switch learns or refreshes it on port 3.
Exercise
Which IPv4 multicast MAC address does the group 224.129.5.9 map to, and which other group in 239.0.0.0/8 shares it?
Show answer
Keep the low 23 bits: the second octet 129 becomes 129 & 0x7f = 1, so the MAC is 01:00:5e:01:05:09. The group 239.1.5.9 maps to the same MAC, as do others that differ only in the top bit of the second octet and the upper five variable bits of the first octet within the multicast range.