PIM: distribution trees, sparse mode and the RPF check

IGMP gets a receiver's request to its own router; routers then need PIM to pull the stream across the network. PIM uses the unicast routing table rather than exchanging routes, and builds a source tree, rooted at the source, or a shared tree, rooted at a rendezvous point. Dense mode floods then prunes; sparse mode sends traffic only where routers join.

In Daveth Pro (Network)9 min video

By , founder of Daveth · Updated

Opening frame of the video walkthrough of PIM: distribution trees, sparse mode and the RPF check

Watch this lesson

9 min · Video walkthrough

In Daveth Pro (Network)

The full 9 min walkthrough is in Daveth Pro (Network). See what the plan opens

What this page answers

What is the difference between PIM dense mode and sparse mode?

Dense mode floods a group's traffic everywhere first and prunes it back where nobody wants it. Sparse mode forwards only where routers have joined, using a rendezvous point as the shared tree's root. Read it in “4.1 Why routers need PIM, and the two kinds of tree”

What is the multicast RPF check?

A router accepts a group's traffic only on its RPF interface: the interface with the lowest-cost unicast path, by AD and then metric, back towards the source or, on a shared tree, towards the RP. Traffic arriving elsewhere fails the check. Read it in the lesson

What is multicast routing?

Routers building a distribution tree for a group with a multicast routing protocol, PIM on Cisco, so one stream reaches every receiver once. PIM is protocol independent: it relies on whatever fills the unicast routing table. Read it in “4.1 Why routers need PIM, and the two kinds of tree”

4.1 Why routers need PIM, and the two kinds of tree

IGMP gets a receiver's request to its own router, and that's enough only if the source sits on that same router; to pull the stream across the network, routers need a multicast routing protocol, and the one Cisco fully supports is Protocol Independent Multicast (PIM). "Protocol independent" means PIM doesn't exchange routes at all: it uses whatever fills the unicast routing table (EIGRP, OSPF, BGP, static routes) and does its checks against that. PIM behaves like a courier firm that owns no maps and borrows the city's road atlas every time it needs a direction.

PIM is called protocol independent because it depends on every routing protocol you run, all at once.

The routers build a distribution tree for the group, and there are two kinds:

TreeRootStateAlso called
source treethe source itself(S,G), "S comma G": one per source per groupshortest path tree (SPT)
shared treea router chosen as the rendezvous point (RP)(*,G), "star comma G": any source to that groupRP tree (RPT)

In the guide's Figure 13-12 the SPT for a source 10.1.1.2 sending to 239.1.1.1 is (10.1.1.2, 239.1.1.1), and every source to a group needs its own. Quiz Q9 checks exactly this: an SPT is rooted at the source, an RPT is a shared tree rooted at the RP. A shared tree keeps less state: however many sources send to 239.1.1.1, the routers near the receivers hold only (*,239.1.1.1). The price is that receivers get every source's traffic for the group, wanted or not, and an unintended source can send into it. Cisco adds that a shared path "might not be the optimal" one. Consider it your choice between a direct courier from each sender and one central sorting office: the hub needs less bookkeeping, and some parcels take the long way round.

In any-source multicast, the (S,G) state a router holds sits under a parent (*,G) entry, which is why the guide's Figure 13-13 shows both on R1 and R2. Both kinds of tree are loop-free, and a packet is copied only where the tree branches.

PIM's words all hang off one direction. Upstream is towards the root of the tree: the source for an SPT, the RP for a shared tree; downstream is towards the receivers. Joins travel upstream; the stream flows downstream. Think of it as a river with the source as the spring: you walk upstream to find where the water comes from.

  • RPF interface: the interface with the lowest-cost path, by AD and then metric, to the source (for an SPT) or to the RP (for a shared tree); it's also the upstream interface and the incoming interface (IIF), the only one that accepts the group's traffic. If two interfaces tie on cost, the guide gives it to the highest IP address (whose address, the interface's or the neighbor's, is unconfirmed). The RPF neighbor is the PIM neighbor on it, and it depends on the tree: in Figure 13-14, R7's RPF neighbor is R3 on the shared tree (towards the RP) and R4 on the SPT (towards the source).
  • Downstream interface, or outgoing interface (OIF): one that forwards the traffic down the tree; the set of them for a group is the outgoing interface list (OIL).
  • Last-hop router (LHR), or leaf router: the one attached to the receivers, which sends the joins upstream. First-hop router (FHR), or root router: the one attached to the source, which registers it with the RP.
  • MRIB, the multicast routing table (the mroute table): source, group, IIF, OIFs and RPF neighbor for each entry, built from the unicast table and PIM. MFIB: the forwarding table programmed from it into hardware. Multicast state: the entries themselves.

In the guide's Figure 13-14, R5's upstream interface is Te0/1/2, because that's its shortest path to the source. If you've ever followed the signs to a river's source, you know the idea: every sign points upstream, towards the spring, and each router's RPF interface is its sign pointing towards the root.

There are five PIM modes: dense (PIM-DM), sparse (PIM-SM), sparse-dense, source-specific (PIM-SSM) and bidirectional (Bidir-PIM); dense and sparse are both any-source multicast (ASM). This lesson is dense and sparse; SSM and bidir are 03-7.

Every PIM control message is IP protocol 103. Registers, register-stops and candidate-RP advertisements (to the BSR, 03-7) are unicast; the others in the guide's table go to 224.0.0.13 (all PIM routers) with a TTL of 1. RFC 7761 also lists dense mode's graft and graft-ack as unicast. The types you'll meet here, with the modes the guide's Table 13-4 lists for each:

TypeMessageSent toUsed by
0Hello224.0.0.13PIM-SM, PIM-DM, bidir, SSM
1Registerthe RP, unicastPIM-SM
2Register-stopthe first-hop router, unicastPIM-SM
3Join/prune224.0.0.13PIM-SM, bidir, SSM
5Assert224.0.0.13PIM-SM, PIM-DM, bidir

The table leaves dense mode out of join/prune, but RFC 3973's dense mode prunes with the same join/prune message format. (Type 9 is dense mode's state refresh; 4 and 8, bootstrap and candidate-RP advertisements, and 10, bidir's DF election, belong to 03-7.) Hellos go out of every PIM interface every 30 seconds by default; they find neighbors, elect the DR and carry options. It's like the roll call at the start of a shift: everyone says they're here, and the list decides who's in charge.

PIM hellos go to 224.0.0.13 with a TTL of 1, so PIM's small talk never gets further than next door.

PIM-DM assumes receivers are everywhere. The source's traffic is flooded out of every interface to every dense-mode router, and a router with nobody downstream who wants it sends a prune back towards the source; the tree that's left is a source tree. The flood produces copies on non-RPF interfaces, as when R3 in Figure 13-15 hears the stream from R2, and those are discarded and pruned too. It acts kind of like a supermarket that posts flyers through every door and waits for the "no junk mail" stickers.

And the stickers fall off. The (S,G) state stays on every router while the source sends, and prunes expire after three minutes, so the traffic floods everywhere again and the pruning starts over. The flood comes back like the junk mail that starts again every time the sticker peels off. RFC 3973 (Experimental) lets the pruning router set the prune's hold time in the message, and adds a state-refresh message to keep prunes alive. The guide's verdict: fine for a lab because it's easy to set up, "not generally recommended for production". Quiz Q13 checks the other half: dense mode uses no RP at all.

Dense mode treats "no thanks" as "ask me again in three minutes", every three minutes, for as long as the source keeps sending.

PIM-SM assumes nobody wants the traffic until they ask. It suits receivers scattered across the network and works where they're dense too, and like dense mode it runs its RPF checks against the unicast table, whichever protocol filled it. Cisco calls it a "pull model". Sparse mode works like a newspaper subscription: nothing lands on the mat until you've asked for it.

The shared tree join. A receiver's IGMP report reaches its LHR (03-5). The LHR knows the RP's address for the group and sends a (*,G) join towards it, hop by hop along its RPF path; each router on the way creates (*,G) state, and the branch runs from the RP to the LHR. Quiz Q10: after an IGMP join, the LHR "sends a PIM join toward the RP".

Registering the source. When the source sends its first packet, its FHR (the DR on that LAN) wraps the packet in a Register message and unicasts it to the RP, through a one-way PIM tunnel. What the RP does next depends on whether anyone has joined:

  • Nobody has. There's no shared tree, so the RP sends a Register-stop straight back to the FHR, and the FHR stops registering. That's quiz Q11. The FHR stays quiet for about a minute (a random time around RFC 7761's 60-second default) and then probes the RP again, and the RP keeps (S,G) state for the source, so it can join as soon as a receiver turns up.
  • Somebody has. The RP unwraps the packet, sends it down the shared tree, and sends an (S,G) join towards the source, which builds (S,G) state on every router between the RP and the FHR. Once packets reach the RP natively along that SPT, it sends the FHR a register-stop. Until then the RP gets each packet twice, tunnelled and native, and drops the tunnelled copy.

Joins and prunes go hop by hop; registers and register-stops don't: they're unicast between the FHR and the RP. The register tunnel itself stays up/up even with no stream, as long as the FHR has an RPF path to the RP. So the stream ends up on two trees: an SPT from the source to the RP, (S,G), and the shared tree from the RP down, (*,G) (Figure 13-17). In a way, it's just a meeting point: the RP is where a source's traffic and the receivers' joins find each other.

The register is multicast's one moment of unicast honesty: the first packet travels to the RP in an envelope with a real address on it.

Before running D1, predict: the first packet reaches R3 through the RP, and R1 is one hop from R3. What does R3 do next, and what happens to the path through R2?

D1

  1. Network drawing: g0/1, g0/2, g0/0, g0/3, R1, FHR · DR, R2, RP, R3, LHR · DR, R4, no receivers, source 10.1.1.2, Receiver A (not joined)

    Step 1 of 6 R2 is the RP for 239.1.1.1, and every router knows it (a static RP; how routers learn the RP is 03-7). The source 10.1.1.2 is quiet, Receiver A hasn’t joined yet, and no router has state for the group.

  2. Network drawing: g0/1, g0/2, g0/0, g0/3, R1, FHR · DR, R2, RP, R3, LHR · DR, R4, no receivers, source 10.1.1.2, Receiver A (joined)

    Step 2 of 6 Receiver A sends an IGMP report. R3, its LHR, creates (*,G) with IIF g0/1, its RPF interface towards the RP, and sends a (*,G) join to its RPF neighbour R2. The RP adds g0/2 to its (*,G) OIL: a branch of the shared tree now runs R2 → R3.

  3. Network drawing: g0/1, g0/2, g0/0, g0/3, R1, FHR · DR, R2, RP, R3, LHR · DR, R4, no receivers, source 10.1.1.2, Receiver A (joined)

    Step 3 of 6 10.1.1.2 starts sending. R1, the DR on the source’s LAN, wraps each packet in a Register and unicasts it to the RP. R2 unwraps it and sends it down the shared tree, so A gets its first packets, and sends an (S,G) join towards the source; R1 adds g0/1 to its (S,G) OIL. Until the register-stop, R2 gets each packet twice, tunnelled and native, and drops the tunnelled copy (RFC 7761 §3).

  4. Network drawing: g0/1, g0/2, g0/0, g0/3, R1, FHR · DR, R2, RP, R3, LHR · DR, R4, no receivers, source 10.1.1.2, Receiver A (joined)

    Step 4 of 6 Native packets now reach R2 on its (S,G) IIF, so it sends R1 a Register-Stop, unicast rather than hop by hop, and R1 stops tunnelling. The stream runs source → R1 → R2 → R3 → A: an SPT from the source to the RP, and the shared tree from the RP down (Figure 13-17).

  5. Network drawing: g0/1, g0/2, g0/0, g0/3, R1, FHR · DR, R2, RP, R3, LHR · DR, R4, no receivers, source 10.1.1.2, Receiver A (joined)

    Step 5 of 6 The first packet told R3 the source’s address. With the default threshold of 0 it sends an (S,G) join towards 10.1.1.2 at once, out g0/0 to R1, its RPF interface for the source. R1 adds that link to its OIL. Once packets arrive on g0/0, R3 sets the T flag and drops the copies still coming down the shared tree on g0/1: they fail the (S,G) RPF check.

  6. Network drawing: g0/1, g0/2, g0/0, g0/3, R1, FHR · DR, R2, RP, R3, LHR · DR, R4, no receivers, source 10.1.1.2, Receiver A (joined)

    Step 6 of 6 R3 prunes the source off the shared tree (the prune goes to R2). R2 removes that link from (S,G); with no other interest it prunes towards R1, which removes g0/1. The stream now runs source → R1 → R3 → A, and the RP is out of the path (Figure 13-18).

PIM-SM lets the LHR leave the shared tree for a source's SPT. On Cisco routers that's the default, and it happens as soon as the first packet arrives down the shared tree, "even if the shortest path to the source is through the RP". The first packet tells the LHR the source's address; it checks its unicast route to the source and sends an (S,G) join hop by hop towards the FHR. When the stream arrives on that SPT, the LHR makes it the RPF interface for the source and prunes the source off the shared tree towards the RP; if the RP now has nobody else downstream for that source, it prunes towards the FHR too (Figure 13-18). It's like your satnav on a second trip: the first time you went through the town centre because that's where the signs pointed; now you know the address, you go direct.

The command reference shows how early "first packet" really is. The default threshold is 0 kbps, so the LHR's (*,G) entry carries the J flag permanently and it "immediately switches to the shortest path source tree when traffic from a new source is received". To keep a group on the shared tree, use ip pim spt-threshold infinity (optionally with a group list); on a 9300 at 17.9, 0 is the only other value it takes. (C1 still describes a kbps threshold.)

Now the surprise. Take the link between R1 and R3 away: R3's best route to the source now runs through R2, the same interface its shared tree uses. R3 still builds (S,G) state and sends the (S,G) join, but it goes the same way as the shared tree, so nothing arrives twice and nothing is pruned: RFC 7761 prunes a source off the shared tree only "if the RPF neighbors differ". Cisco calls the two trees congruent in that case. The guide says the switchover "would still take place" there; both are right, because the switchover changes the state and not the path. Have you ever noticed how a satnav sometimes "reroutes" you onto the road you're already on?

The SPT switchover on Cisco is the only diet that starts after the first bite: one packet down the shared tree and the LHR is already asking for the direct route.

Unicast routing asks where a packet is going. Multicast asks where it came from. Reverse Path Forwarding (RPF) is how a router stops loops and makes sure the traffic arrived on the right interface:

  1. If a multicast packet arrives on the interface the router would use to send unicast to the source, it arrived on the RPF interface.
  2. If so, forward it out of every interface in the entry's OIL.
  3. If not, discard it.

Which address counts as "the source" depends on the state:

  • with an (S,G) entry, the check is against the source's address;
  • with only shared-tree (*,G) state, it's against the RP's address, which is known when members join.

And the same lookup steers the joins: (S,G) joins go towards the source, (*,G) joins towards the RP. It acts kind of like a bouncer who checks which door you came through, not where you're going: arrive through the door that faces your home street and you're in; come round the back and you're out.

In Figure 13-19, R3's route to 10.1.1.0/24 is out of g0/0. A packet from 10.1.1.2 arriving on g0/1 fails and is dropped; the same packet on g0/0 passes and goes out of every OIF. Picture yourself changing an OSPF cost so that R3's best route to 10.1.1.0/24 moves to g0/1: nothing about PIM changed, but the RPF interface moved with the unicast route. If PIM runs along the new path, R3 simply sends its joins that way and the stream follows. If it doesn't, the stream keeps arriving on g0/0 and keeps failing the check: the classic "receivers joined, nothing arrives" fault. The memory hook: joins go up, packets come down, and every router checks the return address.

Multicast routing looks up where a packet came from rather than where it's going, which makes every router in the tree a little bit of a customs officer.

D2

Network drawing: g0/0, g0/1, g0/2, cost 1, R1, R2, R3, source 10.1.1.2 behind R1, RP 10.0.0.2, receivers
R3 has (S,G) state, so it checks the packet against the source: the route to 10.1.1.0/24 leaves by g0/0. The packet came in on g0/1. Wrong interface: discard it, because accepting it could loop (Figure 13-19, left).

With several PIM routers on one LAN, hellos elect a designated router (DR), so the LAN doesn't send duplicate traffic or duplicate registers. The highest DR priority wins (default 1); if the priorities tie, or any router on the segment doesn't advertise a priority, the highest IP address wins. On the source side the DR sends the registers; on the receiver side it sends the joins and prunes and makes the SPT switchover. The DR's hold time is 3.5 times the hello interval, 105 seconds by default; a shorter hello interval (ip pim query-interval) speeds up failover at the cost of more control traffic. It's roughly like the one flatmate who pays the electricity bill: if everybody paid, the company would be paid three times.

Duplicates can still reach a LAN from two upstream routers. When a router sees an (S,G) packet arrive on an interface that is in its own OIL for that (S,G), it knows someone else is forwarding onto the same segment, and both send an assert. The asserts carry the administrative distance and metric of each router's route back to the source, and the winner is:

OrderRule
1the lowest AD to the source
2then the lowest metric
3then the highest IP address