Sub topic 5
Unicast, multicast, and anycast
This chapter assumes you know IPv4 addressing, hexadecimal, CIDR prefix notation, and how IPv6 addresses are written and compressed. Here you will learn how IPv6 classifies addresses by how many hosts receive a packet. Later chapters cover each type in detail.
Three delivery models
Every IPv6 destination address falls into one of three types. The type decides which interfaces receive a packet sent to that address.
| Type | Delivered to | Typical use |
|---|---|---|
| Unicast | One specific interface | Web browsing, SSH, most traffic |
| Multicast | Every interface in a group | Neighbor Discovery, router discovery |
| Anycast | The nearest interface in a group | DNS root servers, CDN services |
IPv6 has no broadcast address. IPv4 broadcast makes every host on a link process each packet. IPv6 replaces it with multicast, so only interested hosts handle the traffic. For example, ff02::1 reaches all nodes on a link, and ff02::2 reaches all routers on a link.
Unicast
A unicast address identifies one interface. The main unicast scopes are:
- Global unicast (
2000::/3): routable on the internet. - Link-local (
fe80::/10): valid only on the local link. - Unique local (
fc00::/7): private addressing inside a site.
Multicast
A multicast address (ff00::/8) names a group. Interfaces join the group and receive its packets. The address contains a scope field, so a group can be limited to one link, one site, or the whole internet.
Anycast
An anycast address is not a separate format. It is a unicast address assigned to several interfaces, usually on different machines. Routing delivers each packet to the closest one, measured by routing metric. If one server fails, routing converges on the next nearest.
Two points need care:
- A host cannot tell from the address alone that it is anycast. You must configure it as anycast.
- Anycast suits stateless request and response services such as DNS. A long TCP session can break if routing changes the nearest server mid-connection.
Classifying addresses in Python
The ipaddress module classifies an address by its prefix, so you can check the type of each address.
import ipaddress
for text in ["::1", "fe80::1", "fd12:3456:789a::1", "ff02::1"]:
a = ipaddress.ip_address(text)
print(text, a.is_loopback, a.is_link_local, a.is_private, a.is_multicast)
# ::1 True False True False
# fe80::1 False True True False
# fd12:3456:789a::1 False False True False
# ff02::1 False False False TrueThe module has no is_anycast property. Anycast addresses look like ordinary unicast ones, which shows the point above.
Exercise
A service runs on three servers in different cities, and all three are configured with the same address. Clients reach the closest one. Which address type is this? Why is it a poor fit for a long-lived file transfer over TCP?
Show answer
It is anycast. Routing picks the nearest server for each packet. If routes change during a transfer, later packets can reach a different server that has no record of the TCP connection, so the session breaks.
Exercise
Which prefix identifies a multicast address, and what replaces IPv4 broadcast for reaching all hosts on a link?
Show answer
Multicast addresses use ff00::/8. The all-nodes multicast address ff02::1 replaces broadcast on a link.