Friday, February 21, 2020

Multicast PIM Assert Explained

Multicast PIM Assert is one of those important multicast topics that most people don’t really think about. Let’s take a look at the following topology:
multicast assert
Above you see 4 routers that are configured to use multicast. R1 is the source and R4 is our receiver. As you can see R2, R3 and R4 are connected to the same switch.
Now when R1 starts streaming multicast traffic towards R2 and R3 they will both forward multicast packets to R4 resulting in duplicate traffic. To stop this PIM will elect one PIM forwarder for this segment. PIM doesn’t have any routing information itself but relies on other routing protocols that are configured, it will use this information to select the best forwarding path with the PIM assert mechanism.
Don’t confuse the PIM forwarder with the PIM DR (Designated Router). those are two different things!
When R2 and R3 both forward multicast packets to the 192.168.234.0 /24 segment they will see each others multicast traffic, this will trigger the PIM assert mechanism. We will elect a PIM forwarder based on the following rules:
  1. The router with the lowest administrative distance to the source of the multicast stream will be the elected PIM forwarder. This only happens if you are using two routing protocols or if you used a static route pointing to the source.
  2. If the AD is equal we will compare the unicast routing metric towards the source.
  3. If the AD and metric are both the same we will elect the PIM forwarded based on the highest IP address.
The elected PIM forwarder will keep forwarding traffic to the receiver while the loser will prune its interface.
Now let’s take a look at this in action! First i’ll configure a basic PIM Dense mode setup:
R1(config)#ip multicast-routing 

R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.255
R1(config-if)#ip pim dense-mode 

R1(config)#interface fastEthernet 0/0
R1(config-if)#ip pim dense-mode         

R1(config)#interface fastEthernet 0/1
R1(config-if)#ip pim dense-mode 
I will use a loopback interface on R1 as the source for our multicast stream.
R2(config)#ip multicast-routing 

R2(config)#interface fastEthernet 0/0
R2(config-if)#ip pim dense-mode 

R2(config)#interface fastEthernet 0/1
R2(config-if)#ip pim dense-mode
R3(config)#ip multicast-routing 

R3(config)#interface fastEthernet 0/0
R3(config-if)#ip pim dense-mode 

R3(config)#interface fastEthernet 0/1
R3(config-if)#ip pim dense-mode
R2 and R3 are simple, just enable multicast routing and PIM Dense mode on the interfaces. Only R4 left:
R4(config)#ip multicast-routing 

R4(config)#interface fastEthernet 0/0
R4(config-if)#ip pim dense-mode 
R4(config-if)#ip igmp join-group 239.1.1.1
On R4 we will also enable PIM dense mode and we make it listen to the 239.1.1.1 multicast group address.
I applied OSPF to all routers, using the quick “shotgun approach” to advertise everything:
router ospf 1
 network 0.0.0.0 255.255.255.255 area 0
Now let’s start a multicast stream from R1:
R1#ping 239.1.1.1 source loopback 0 repeat 9999

Type escape sequence to abort.
Sending 9999, 100-byte ICMP Echos to 239.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1 

Reply to request 0 from 192.168.234.4, 12 ms
You will see replies from R4. Now let’s check who is forwarding this traffic:
R2#show ip mroute 1.1.1.1 239.1.1.1
IP Multicast Routing Table
Flags: D - Dense, S - Sparse, B - Bidir Group, s - SSM Group, C - Connected,
       L - Local, P - Pruned, R - RP-bit set, F - Register flag,
       T - SPT-bit set, J - Join SPT, M - MSDP created entry,
       X - Proxy Join Timer Running, A - Candidate for MSDP Advertisement,
       U - URD, I - Received Source Specific Host Report,
       Z - Multicast Tunnel, z - MDT-data group sender,
       Y - Joined MDT-data group, y - Sending to MDT-data group
Outgoing interface flags: H - Hardware switched, A - Assert winner
 Timers: Uptime/Expires
 Interface state: Interface, Next-Hop or VCD, State/Mode

(1.1.1.1, 239.1.1.1), 00:02:56/00:00:07, flags: PT
  Incoming interface: FastEthernet0/0, RPF nbr 192.168.12.1
  Outgoing interface list:
    FastEthernet0/1, Prune/Dense, 00:02:56/00:00:03
R3#show ip mroute 1.1.1.1 239.1.1.1  
IP Multicast Routing Table
Flags: D - Dense, S - Sparse, B - Bidir Group, s - SSM Group, C - Connected,
       L - Local, P - Pruned, R - RP-bit set, F - Register flag,
       T - SPT-bit set, J - Join SPT, M - MSDP created entry,
       X - Proxy Join Timer Running, A - Candidate for MSDP Advertisement,
       U - URD, I - Received Source Specific Host Report,
       Z - Multicast Tunnel, z - MDT-data group sender,
       Y - Joined MDT-data group, y - Sending to MDT-data group
Outgoing interface flags: H - Hardware switched, A - Assert winner
 Timers: Uptime/Expires
 Interface state: Interface, Next-Hop or VCD, State/Mode

(1.1.1.1, 239.1.1.1), 00:02:48/00:02:57, flags: T
  Incoming interface: FastEthernet0/0, RPF nbr 192.168.13.1
  Outgoing interface list:
    FastEthernet0/1, Forward/Dense, 00:02:48/00:00:00, A
As you can see above R2 has pruned its outgoing interface while R3 is forwarding it. Note that you also see the “A” indicating that R3 is the assert winner. R3 has won this PIM assert election because it has the highest IP address. Let’s change the AD on R2 to see if it becomes the new assert winner:
R2(config)#router ospf 1
R2(config-router)#distance 100 0.0.0.0 255.255.255.255 1 
R2(config)#access-list 1 permit host 1.1.1.1
We will change the AD on R2 to 100 for all prefixes matching access-list 1. Access-list 1 matches 1.1.1.1 which is the source of our multicast stream.
Keep in mind that when we work with multicast we are concerned about source IP addresses, not destination IP addresses like with unicast routing.
Let’s verify our work:
R2#show ip route | include 1.1.1.1
O       1.1.1.1 [100/11] via 192.168.12.1, 00:01:32, FastEthernet0/0
R3#show ip route | include 1.1.1.1
O       1.1.1.1 [110/11] via 192.168.13.1, 00:01:20, FastEthernet0/0
R2 now has a better administrative distance so it should win the PIM assert election, let’s see if this is true:
R2#show ip mroute 1.1.1.1 239.1.1.1
IP Multicast Routing Table
Flags: D - Dense, S - Sparse, B - Bidir Group, s - SSM Group, C - Connected,
L - Local, P - Pruned, R - RP-bit set, F - Register flag,
T - SPT-bit set, J - Join SPT, M - MSDP created entry,
X - Proxy Join Timer Running, A - Candidate for MSDP Advertisement,
U - URD, I - Received Source Specific Host Report,
Z - Multicast Tunnel, z - MDT-data group sender,
Y - Joined MDT-data group, y - Sending to MDT-data group
Outgoing interface flags: H - Hardware switched, A - Assert winner
Timers: Uptime/Expires
Interface state: Interface, Next-Hop or VCD, State/Mode

(1.1.1.1, 239.1.1.1), 00:00:11/00:02:53, flags: T
Incoming interface: FastEthernet0/0, RPF nbr 192.168.12.1
Outgoing interface list:
FastEthernet0/1, Forward/Dense, 00:00:11/00:00:00, A
There we have it, the “A” tells us that R2 is now the PIM assert winner. Let’s remove the lowered AD to play with the metric:
R2(config)#router ospf 1
R2(config-router)#no distance 100 0.0.0.0 255.255.255.255 1
This will make R3 the forwarder again. We will now increase the cost on the FastEthernet0/0 link of R3 so that it’s metric to the source is worse than R2:
R2#show ip ospf interface fa0/0 | include Cost
  Process ID 1, Router ID 192.168.234.2, Network Type BROADCAST, Cost: 10
R3#show ip ospf interface fa0/0 | include Cost
  Process ID 1, Router ID 192.168.234.3, Network Type BROADCAST, Cost: 10
The default cost of the FastEthernet links is 10 on R2 and R3. Let’s increase it on R3:
R3(config)#interface fastEthernet 0/0
R3(config-if)#ip ospf cost 11
This is now the metric for R2 and R3 to reach the loopback0 interface of R1:
R2#show ip route ospf | include 1.1.1.1
O       1.1.1.1 [110/11] via 192.168.12.1, 00:06:58, FastEthernet0/0
R3#show ip route ospf | include 1.1.1.1
O       1.1.1.1 [110/12] via 192.168.13.1, 00:00:44, FastEthernet0/0
R2 has a lower metric to reach the source of the multicast stream so it will be the PIM assert winner:
R2#show ip mroute 1.1.1.1 239.1.1.1 | begin FastEthernet0/1
    FastEthernet0/1, Forward/Dense, 00:01:41/00:00:00, A
And you can see this in the output above. If you want to see what it looks like behind the scenes you can also enable a debug:
R2#debug ip pim
PIM debugging is on
You will see something like this:
Send v2 Assert on FastEthernet0/1 for 239.1.1.1, source 1.1.1.1, metric [110/11] 
PIM(0): Assert metric to source 1.1.1.1 is [110/11]
PIM(0): We win, our metric [110/11]
PIM(0): (1.1.1.1/32, 239.1.1.1) oif FastEthernet0/1 in Forward state
PIM(0): Received v2 Assert on FastEthernet0/1 from 192.168.234.3
PIM(0): Assert metric to source 1.1.1.1 is [110/12]
PIM(0): We win, our metric [110/11]
PIM(0): (1.1.1.1/32, 239.1.1.1) oif FastEthernet0/1 in Forward state
hostname R1
!
ip cef
!
ip multicast-routing
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
 ip pim dense-mode
!
interface FastEthernet0/0
 ip address 192.168.12.1 255.255.255.0
 ip pim dense-mode
!
interface FastEthernet0/1
 ip address 192.168.13.1 255.255.255.0
 ip pim dense-mode
!
router ospf 1
 network 0.0.0.0 255.255.255.255 area 0
!
end
hostname R2
!
ip cef
!
ip multicast-routing
!
interface FastEthernet0/0
 ip address 192.168.12.2 255.255.255.0
 ip pim dense-mode
!
interface FastEthernet0/1
 ip address 192.168.234.2 255.255.255.0
 ip pim dense-mode
!
router ospf 1
 network 0.0.0.0 255.255.255.255 area 0
!
access-list 1 permit 1.1.1.1
!
end
hostname R3
!
ip cef
!
ip multicast-routing
!
interface FastEthernet0/0
 ip address 192.168.13.3 255.255.255.0
 ip pim dense-mode
 ip ospf cost 11
!
interface FastEthernet0/1
 ip address 192.168.234.3 255.255.255.0
 ip pim dense-mode
!
router ospf 1
 network 0.0.0.0 255.255.255.255 area 0
!
end
hostname R4
!
ip cef
!
ip multicast-routing
!
interface FastEthernet0/0
 ip address 192.168.234.4 255.255.255.0
 ip pim dense-mode
 ip igmp join-group 239.1.1.1
!
router ospf 1
 network 0.0.0.0 255.255.255.255 area 0
!
end
I hope this explanation and walkthrough help you understand PIM assert. If you have any questions feel free to leave a comment!

No comments:

Post a Comment