Sunday, November 29, 2015

Multicast - Part1

PIM:
224.0.0.13 multicast group for all PM routers.
Sends hello message every 30sec and hold down timer three times of hello interval.
Highest priority router will become DR for the segment, if priorities are equal, router with highest ip will become DR. (Sending PIM register and PIM join and prune messages toward the RP, Sending IGMP host-query messages.)
RPF check is done to ensure the packet arrived on the correct interface in the direction of source.
When multiple entries exist in the routing table, the entry with the highest next-hop will get selected.

PIM DM:

PIM-DM builds source-based multicast distribution trees that operate on a "flood and prune" principle.

In dense mode, prune messages are sent when
Traffic arrives on non-RPF interfaces
No receivers

Prune override:
On multi access networks, if routers sees a prune message and has receivers, it will send join message to override the prune message.
A 3 second prune delay timer is started on receiving a prune message, if no join is received in this 3 sec prune will take place.

PIM asserts:
On multi-access networks to avoid duplicate multicast traffic.
If a router receives a multicast packet via an interface in the outgoing interface list associated with a multicast source, send a PIM Assert message out the interface to resolve which router will continue forwarding this traffic. The router with better metric to the source will win and continue to relay multicast traffic.
If tie in metric, the router with highest ip will win.

PIM graft:
To restart the flow of multicast traffic on a previously pruned interface without having to wait for the timers to expire.


PIM State refresh capability
If state refresh is enabled on an interface, the router will send a mcast control packet, if the receiving has no interfaces in OIL, it will send a prune back to sender refreshing the state.


If  PIM dense mode (PIM-DM) is enabled on a router interface, the PIM Dense Mode State Refresh feature is also enabled by default.

General Rules in forwarding multicast traffic:
The multicast traffic is forwarded using mroute tables, the following rules help in understanding the mroute tables
·         When creating (S, G) entry, create (*, G) if it doesn’t exists
·         The RPF interface will be calculated as the interface with lowest cost to the source in case of (S, G) and with lowest cost to the RP in case of sparse mode (*, G).If multiple interfaces have the same cost, the interface with highest IP will become the RPF interface.
·         When creating (S,G) entry, its outgoing interface list(OIL) is copied from the parent (*,G)
·         The incoming interface of a multicast forwarding entry  must never appear in the OIL
·         The RPF interface of every multicast state entry will be calculated every 5 sec and the OIL is adjusted according with the rules.
·         Addition/deletions to the outgoing interface list of (*, G) are replicated to the associated (S, G) entries.


Sparse Mode:
Unlike dense mode, sparse mode uses (*, G) to forward multicast traffic.

Sparse mode (*, G) rules:
·         A (*, G) is created as a result of explicit join operation. Due to a directly connected host joining the group or in response to (*, G) join request downstream router
·         The incoming interface of (*, G) always points up the shared tree towards the RP.

Sparse mode (S, G) rules:
·         A (S, G) entry is created on receiving a (S,G) join/prune message or last hop router deciding to switchover to shortest path or unexpected arrival of (S,G) traffic or RP on getting register message
·         When a (*, G) join is received, the interface is added to the outgoing interface list of (*, G) and subsequently to (S,G)
When a (S, G) join is received, the interface is added to the OIL of (S, G) only. The (S, G) join is specific to SPT for source S and group G and is not applicable to the shared tree.
·         The interface is removed from OIL on receiving a (*, G) or (S, G) prune or interface expiration timer counts to zero.
·         The expiration timer is reset on receiving a (*, G) or (S, G) join or IGMP membership report. Downstream routers will refresh the state by sending the joins periodically every minute.
·         When the last hop router decides to switch to shortest path, the router no longer needs to receive the traffic via shared tree. To stop the flow of this redundant traffic  down the shared tree,
router will send (S, G) prune with RP bit set. Router receiving the prune message sees this message as a request to prune the specified (S, G) traffic from this branch of the shared tree.
Router will send an (S, G) RP-bit prune when the RPF interface of (*, G) is different from RPF interface of (S, G) i.e. shortest path.
·         When the router receives an (S, G) RP-bit set prune from a downstream neighbor, it will remove the interface from the OIL of (S, G) and sets the R flag.
·         The RPF of (S, G) is calculated by using the IP address of the source except when RP bit is set, in which case the IP address of RP is used(Incoming interface)





Say R3 and R4 have sent join for the group G1.
At this point, all the routers R2, R3, R4 and RP will have (*, G1) entries.

When the source starts sending traffic, RP will forward the multicast traffic and subsequently it reaches R3 and R4.
R3 sees that it has shortest path to the source and will send an (S, G1) join to R1 and (S, G1) RP-bit prune to R2.
R2 will create (S, G1) state and set the R flag and copies the OIL from (*, G1) and removes the interface S1 from it.
R3 will get the traffic from R1 directly and R4 will continue to get the traffic from shared tree. At the point, the (S, G1) entry in R2 will also have a flag T indicating the traffic is forwarded via the (S, G1) entry.

Prunes are sent up the shared tree to prune off sources whose traffic is being received directly via the SPT along a different path. These (S, G)RP-bit Prunes must continue to be sent periodically along with the associated (*, G) Join to refresh state along the shared tree. When these periodic Joins are sent up the shared tree, both the (*, G) Join and any associated (S, G) RP-bit Prunes are all sent inside of the same PIM Join/Prune message. This leads to the following two categories of (*, G) Joins:
Atomic (*, G) Joins---These are Join/Prune messages that contain both the (*, G) Join along with all associated (S, G)RP-bit Prunes for Group G.
 Nonatomic (*, G) Joins---These are Join/Prune messages that contain only the (*, G) Join without any associated (S, G)RP-bit Prunes for Group G.



If the source joins first, Register, Register-stop sequence will continue to happen until some receiver joins.

SPT Switchover:
Once each second, the router will compute the total traffic flowing down the shared tree.
If this exceeds the threshold, the router will set the J flag on (*, G) and join the (S, G) on arrival of next packet.
Here are the steps
·         Set J flag on (*, G) and wait for the next (S, G)
·         When (S, G) arrives down the shared tree, clear J flag on (*, G) and send (S, G) join.
The J flag will again be set after 1 sec interval on (*, G).This is to avoid multiple (S, G) switchovers.
·         Once the traffic is pruned of the shared tree and traffic arrives on (S, G),the router will continue o calculate the rate of traffic on (S, G)
 If the rate is lower than the threshold, the router will switchover to shared tree and prune off the flow down the SPT.


Pruning:
Shared Tree: If router no longer wants multicast traffic it will send (*, G) prune.
When (*, G) prune is received, the interface is removed from OIL. If the OIL is null, the P flag is set on the (*, G) and a prune is sent to upstream router.

Shortest Tree: If router no longer wants multicast traffic it will send (*, G) prune up the SPT.
No (S, G) prune will be sent, instead P flag is set on the (S, G) and expire timer is triggered on them and allowed to age out.


R4 will not send (S, G) prune, it will start expire timer on (S, G) and will send (*, G) prune up the shared tree.
R4 will also not send periodic (*, G) and (S, G) joins to refresh the state.

When (*, G) prune arrives at R2, it will send the (*, G) prune up the shared tree and start expiration timer on (S, G).
The source will continue to send the (S, G) traffic and on arrival of (S, G), the router R2 will send (S, G) prune.

The reason that (S, G) Prunes are triggered only by the arrival of data is to optimize the amount of control traffic sent in the network, bandwidth is not wasted sending (S, G) Prunes for bursty or other low-rate sources in the network.

Turnaround Router:
The turnaround router scenario occurs when the SPT and shared tree paths merge at a router (with traffic flowing in opp directions).
The router at which the paths merge is called turnaround router, it is upstream of the shared tree receivers and downstream of the source on the SPT




Proxy join timer is used to handle such scenario, it is associated only with (S,G) entries in the mroute table.
Rules:
A proxy-join timer is started on RP when the (S, G) entry is created by a register message and OIL of (*, G) is not null.
When the router receives a non-atomic (*, G) join on the incoming interface of (S, G) entry from a non RPF neighbor.

The proxy-join timer is reset by the receipt of non-atomic joins,
They are simply allowed to age out if the non-atomic joins are not received.

                When the proxy-join timer is running on an (S, G) entry,
                The router will send (S, G) joins towards the source and suppress sending (S, G) prunes towards the source.

Say R2 has a receiver and it joins the shared tree.
·         When a source starts sending at R1, it will send register message to RP.
·         RP will have (*, G) with OIL, so it will start proxy join timer and starts sending (S, G) joins towards the source.Ideally,the OIL of (S, G) on RP will be null and it should have been sending prunes.
·         Once the SPT is built, R3 will hear the non-atomic join sent by R2 and it will start its proxy-join timer.
·         R3 will start sending (S, G) joins towards the source and will also send atomic joins towards RP. Atomic joins will be sent because RPF of (*, G) and (S, G) are different(PIM SM rules,prune with rp bit set).
·         The proxy join timer will be reset by non-atomic joins, since RP is receiving atomic joins, the proxy join timer on RP will age out
·         When the timer expires on RP, it will not send periodic (S, G) joins to R3 and the interface will eventually be removed from OIL of (S, G) in R3.

The turnaround router functionality will not work if R2 switches over to SPT.This is because, it will be sending atomic joins.