Back to all articles
AnycastMulticastRoutingBGP

Unicast, Multicast, and Anycast: How Data Finds an Audience

David ChenJune 28, 2024

When you first learn about networking, the rules seem very rigid. One computer gets one MAC address. One computer gets one IP address. When you send a packet, it goes from one specific sender to one specific receiver.

This 1-to-1 communication is called Unicast. It is how 99% of the internet works. When you load a web page, you are establishing a Unicast connection with the server.

But Unicast is incredibly inefficient for certain types of tasks. Over the decades, network engineers invented new ways to route traffic: Broadcast, Multicast, and the mind-bending concept of Anycast.

Let's break them down.

Unicast: 1-to-1

As mentioned, this is standard communication. It is a private telephone call between two people. If a server wants to send a video stream to 100 different people using Unicast, the server has to duplicate the video 100 times and send 100 separate streams of data out of its network port. This consumes massive bandwidth.

Broadcast: 1-to-All

We discussed Broadcasts in the ARP and DHCP blogs. A Broadcast is a packet sent to the special address `255.255.255.255`.

It is someone standing in the middle of an office with a megaphone shouting, "IS ANYONE HERE THE PRINTER?"

Every single computer on the local network is forced to stop what it's doing, listen to the packet, and process it. Because broadcasts are so noisy and disruptive, routers absolutely refuse to forward them. A broadcast packet will never, ever leave your local network.

Multicast: 1-to-Many (Subscribers Only)

Imagine you are running a live corporate training video for 5,000 employees in an office building.

If you use Unicast, your server crashes trying to send 5,000 copies of the video. If you use Broadcast, you flood the entire network, and people who aren't even watching the video have their computers slowed down processing the junk traffic.

Enter Multicast.

Multicast is like a radio station. The server sends out *only one* stream of data, addressed to a special Multicast IP Address (e.g., `224.0.0.5`).

If a computer wants to watch the video, it "tunes in" to that IP address by telling the local network switch, "Hey, I want to subscribe to this multicast group."

The network switches and routers do all the hard work. They take the single incoming stream of video and duplicate it *only* down the specific cables where there are active subscribers. The people who didn't subscribe hear nothing. It is incredibly efficient.

Anycast: 1-to-Nearest (The Magic Trick)

Unicast, Broadcast, and Multicast all make logical sense.

Anycast breaks the fundamental rule of networking. In Anycast, you take a single IP address—for example, `8.8.8.8` (Google's Public DNS)—and you assign that exact same IP address to 500 different physical servers located all over the globe.

How is this possible? If I send a packet to `8.8.8.8`, which server does it go to?

It goes to whichever server is physically closest to you.

This magic is achieved using BGP (the routing protocol we discussed in the previous blog).

Google puts a server in New York, assigns it the IP `8.8.8.8`, and tells the New York routers via BGP: "I am here."

Google puts another server in Tokyo, assigns it the exact same IP `8.8.8.8`, and tells the Tokyo routers via BGP: "I am here."

If you live in New Jersey and you ping `8.8.8.8`, your ISP looks at its BGP map. It sees two paths to `8.8.8.8`. The path to New York is 2 hops away. The path to Tokyo is 15 hops away. The ISP naturally sends your packet to New York. You get a lightning-fast response.

If a user in Kyoto pings `8.8.8.8`, their ISP also looks at its BGP map. For them, Tokyo is 2 hops away, and New York is 15 hops away. The Japanese user's packet is routed to Tokyo.

They both pinged the exact same IP address, but they talked to two entirely different physical servers.

Why Use Anycast?

Anycast is the secret weapon of CDNs (Content Delivery Networks) like Cloudflare and Akamai, and it is how global DNS systems survive.

1. Extreme Speed: Because BGP automatically routes the user to the closest physical server, latency is drastically reduced.

2. Load Balancing: You don't need a massive, centralized load balancer. The architecture of the internet *itself* acts as the load balancer, naturally dividing global traffic regionally.

3. DDoS Protection: If a hacker launches a massive Distributed Denial of Service (DDoS) attack from a botnet in Russia against an Anycast IP address, the attack doesn't bring down the whole system. The BGP routers naturally funnel all the Russian botnet traffic into the Russian Anycast server. The Russian server might melt, but users in the US and Europe will continue being routed to their local servers, completely unaffected by the attack.

Anycast takes the chaotic, decentralized nature of the internet and turns it into a feature rather than a bug.