Multicast Routing
PIM-SM, PIM-DM, and IGMP for efficient one-to-many communication.
Introduction: Beyond One-to-One Communication
Most of our daily interactions on the internet are based on a one-to-one, or unicast, model. When you browse a website, your computer sends a request to a single web server, and that server sends a reply back only to you. It is like sending a private letter. This is efficient for most tasks, but it becomes incredibly inefficient for applications that need to send the exact same data to many people at the same time.
Imagine a live broadcast of a major sporting event online. If the provider used unicast, their server would have to create a separate, identical copy of the video stream for every single viewer. With millions of viewers, this would require an impossible amount of server power and network bandwidth.
On the other extreme is broadcast communication. A broadcast is like a town crier shouting a message in the town square. Every single person in the area hears it, whether they are interested or not. In networking, a broadcast packet is delivered to every device on a local network segment. This is useful for certain discovery tasks but is extremely wasteful and disruptive for large-scale data delivery, as it floods the network and interrupts devices that do not need the information.
Multicast routing is the elegant solution that sits between these two extremes. It provides efficient and scalable one-to-many and many-to-many communication. The analogy for multicast is not a private letter or a town crier, but a magazine subscription. The publisher sends out only one copy of the magazine, and the postal service intelligently replicates it along the delivery routes so that a copy only lands in the mailbox of those who have subscribed. Everyone else on the street is left undisturbed. This is the core principle of multicast routing.
Core Multicast Concepts
To understand how multicast works, we need to define its key building blocks.
- Multicast Group: This is a collection of receivers interested in a particular data stream. For our magazine analogy, the group would be all the subscribers to "National Geographic." Anyone can join or leave a group at any time.
- Multicast Group Address: Every multicast group is identified by a single, unique IP address. A special range of IP addresses, known as , is reserved for this purpose. The range is from to . When a source sends a packet to a multicast group address, the network's job is to deliver that packet to all subscribed members of the group.
- Distribution Tree: The network builds a delivery path from the data source to all the receivers. To be efficient, this path must be a loop-free tree structure. A packet is sent once down each branch of the tree, and network routers automatically replicate the packet at any point where the tree branches off in multiple directions.
IGMP: How Receivers Subscribe to a Group
The first problem to solve is: how does a local router know that a computer on its network wants to join a multicast group? The router cannot magically read the user's mind when they click play on a video stream. The protocol that manages this local group membership is the Internet Group Management Protocol (IGMP).
IGMP operates only between a host (e.g., your computer) and its directly connected, last-hop router.
The IGMP Conversation
- The Router Asks: Periodically, the router sends out an IGMP Membership Query message to a special address (, all-hosts multicast address) on its local network. This is like the router asking, "Is anyone on this street still interested in receiving any magazines?"
- Hosts Reply: When a host's application wants to join a multicast group (e.g., you start streaming IPTV on channel ), the host's operating system sends an IGMP Membership Report (also called a Join message) for that group address. This is the host raising its hand and saying, "Yes, please deliver mail for group to this address!" The host will also send a report in response to the router's periodic query.
- The Router Listens: The router maintains a list of which multicast groups have at least one active member on its local network. As long as it keeps receiving reports for a group, it knows it needs to keep delivering traffic for that group.
IGMP Versions and Leaving a Group
IGMP has evolved to become more efficient:
- IGMPv1: The original. It had no explicit "leave" message. When a host wanted to leave, it simply stopped sending reports. The router had to wait for a timeout (a few minutes) before it assumed no one was interested anymore, which was slow.
- IGMPv2: A major improvement that introduced an explicit Leave Group message. Now, when a user changes the channel, their host can immediately tell the router, "I am no longer interested in group ." This allows the router to stop forwarding unnecessary traffic much more quickly. It also introduced a querier election mechanism on networks with multiple routers.
- IGMPv3: The most advanced version. It added support for Source-Specific Multicast (SSM). A host can now request traffic not just for a group, but for a group from a specific source IP address. "I only want the video stream for group if it's coming from the server at ." This enhances security and efficiency.
PIM: How Routers Build the Distribution Tree
IGMP solves the local problem. Now the router knows that someone on its street wants a subscription. But how does the router get the magazine from the publisher, who might be hundreds or thousands of kilometers away across the internet? This is the job of a true multicast routing protocol. The most widely used is Protocol Independent Multicast (PIM).
The "Protocol Independent" part is important. PIM does not have its own metric for choosing paths. Instead, it leverages the existing that has already been built by an IGP like OSPF or a static route. PIM comes in two main flavors, or modes, which represent two completely different strategies for building the distribution tree.
PIM Dense Mode (PIM-DM): The Flood-and-Prune Approach
Dense Mode operates on the assumption that group members are densely distributed throughout the network: meaning, almost everyone is interested in the multicast traffic. It therefore uses a simple "push" model.
Analogy: The Firehose. PIM Dense Mode is like a firefighter spraying water with a firehose. Initially, they spray water everywhere, flooding the entire area. Then, people who are not on fire shout, "Stop spraying me!" The firefighter then stops spraying in those directions.
How PIM-DM Works
- Initial Flood: When a source starts sending multicast traffic, its first-hop router initially floods that traffic out of all its PIM-enabled interfaces. Routers that receive this traffic continue to flood it downstream. The traffic is aggressively pushed throughout the entire network.
- Prune Messages: A router that receives the flooded traffic checks if it has any need for it. If it has no downstream neighbors that want the traffic (i.e., it has received no IGMP reports or PIM Joins for that group), and it has no directly connected hosts that want it, it sends a Prune message back upstream to the router that sent it the traffic.
- Building the Tree: This prune message tells the upstream router, "You can stop sending me this traffic." The upstream router then "prunes" that interface from its distribution tree for that group. This process continues until only the branches of the tree leading to active receivers remain. The result is an optimal, source-based tree called the Shortest Path Tree (SPT).
- State Refresh: The pruned state is not permanent. After a timeout (typically 3 minutes), the pruned branches automatically "grow back" and traffic is briefly flooded again. This allows new members to join the stream.
Pros and Cons of PIM-DM
- Pro: Simple to configure and provides fast initial delivery for receivers.
- Con: The initial flooding is extremely inefficient and not scalable. It wastes a significant amount of bandwidth across the entire network, especially if there are very few receivers. Because of this, Dense Mode is rarely used in modern networks and is only suitable for small, contained environments where most devices are expected to be multicast receivers.
PIM Sparse Mode (PIM-SM): The On-Demand Approach
Sparse Mode is the complete opposite of Dense Mode. It operates on the assumption that group members are sparsely distributed: meaning, only a small fraction of potential receivers are interested in any given multicast stream. This is the case for most applications on the Internet. PIM-SM therefore uses a receiver-initiated, "pull" model.
Analogy: The Central Post Office. PIM Sparse Mode works like a highly organized postal service. Traffic is not just flooded everywhere. Instead, interested receivers (subscribers) send a request to a central meeting point (the Post Office). The sender (publisher) also sends a single copy of its data to this central point. The Post Office is then responsible for connecting the two and ensuring delivery only to those who have requested it.
The Rendezvous Point (RP)
The heart of PIM-SM is a special router called the Rendezvous Point (RP). The RP acts as the initial "meeting point" for a multicast group. Its address must be known by all routers in the PIM domain.
How PIM-SM Works
- Receiver Joins: A host sends an IGMP Report to join a group. Its local router receives this and, knowing the address of the RP, sends a PIM Join message towards the RP. This message travels hop-by-hop, building a branch of a distribution tree that connects the receiver to the RP. This initial tree is called the Shared Tree (*,G).
- Source Sends Data: A source starts sending multicast packets. Its local router intercepts these packets. It encapsulates the first few multicast packets inside special unicast Register messages and sends them directly to the RP. This informs the RP that there is an active source for the group.
- RP Forwards Traffic: The RP receives the data from the source. It now knows there is at least one active receiver (from the Join message) and has the data from the source (from the Register message). The RP starts forwarding the multicast traffic down the Shared Tree towards the receivers. At this point, traffic is flowing, but it is taking a potentially suboptimal path via the RP.
- Switchover to the Shortest Path Tree (SPT): As soon as the receiver's local router starts getting traffic from the RP, it learns the true IP address of the original source from the packet headers. Now, it can use its own unicast routing table to determine the most direct path to the source. It sends a new PIM Join message directly towards the source. This builds a second, optimal tree branch, the Shortest Path Tree (S,G).
- Pruning the Shared Tree: Once traffic starts arriving via the new, optimal SPT, the receiver's router sends a Prune message back up towards the RP to stop the duplicate traffic from the shared tree. The inefficient path via the RP is torn down, and traffic now flows on the most efficient path.
Pros and Cons of PIM-SM
- Pro: Highly scalable and efficient. No traffic is forwarded unless it is explicitly requested. This is the de-facto standard for multicast on the internet and in large enterprise networks.
- Con: More complex to configure and manage due to the need for an RP. There can be slightly more latency for the first packets to arrive as they must travel through the RP before the SPT switchover.
Reverse Path Forwarding (RPF): The Sanity Check
A critical mechanism used by all multicast routing protocols to prevent loops and duplicate packets is Reverse Path Forwarding (RPF).
Analogy: The Return Address Check. When you receive a letter, you can look at the sender's address. RPF is like asking a simple question: "If I wanted to send a reply to this sender, would I use the same road that this letter just arrived on?" If the answer is yes, the letter is probably legitimate. If the answer is no (e.g., a letter from your bank in New York arrived via a local back alley), something is wrong.
The RPF check is a simple but effective rule: when a router receives a multicast packet, it looks at the packet's source IP address. It then performs a lookup in its regular unicast routing table to see which interface it would use to send a packet to that source. If the multicast packet arrived on that same interface, the RPF check passes, and the packet is accepted and forwarded. If the packet arrived on any other interface, the RPF check fails, and the packet is discarded as a probable duplicate or part of a routing loop.