# Enhanced Multicast Repair Fast Reroute Mechanism for Smart Sensors IoT and Network Infrastructure
## 4 M-REP FRR Mechanism
### M-REP State Machine  
For a logical representation of the M-REP mechanism, state diagrams are created for S router (Figure 5), as well as D and R routers (Figure 6).  
The M-REP process of the mentioned routers can move between the states described in the Table 3:  
Figure 5: The M-REP mechanism state diagram of router S.  
Figure 6: The M-REP state diagram for D and R routers.  
\begin{table}
\begin{tabular}{l l} \hline \hline
**State:** & **Any Condition** \\ \hline Event: & - \\ New state: & Init \\ Action: & Initializing the M-REP mechanism on the router. The mechanism is initialized only for the first time. After this action, it is in the monitoring mode. \\ \hline
**State:** & **Init** \\ \hline Event: & Failure of a protected interface \\ New state: & Router S \\  & If the router detects a connectivity failure on the output interface during the processing of protected packet flow (defined by source, destination addresses), it becomes router S. After the failure is detected, all packets within a protected flow are encapsulated with an additional packet header (source, M-REP add). \\ Action: & Router S does not have an input RPF interface for the multicast flow, which means that it \\  & discards the packet (s) with the destination multicast address (M-REP add). \\  & Note: Deactivation of the M-REP mechanism can also be performed using a timer set to a time, which will ensure that the convergence process in the network has completed. In this case, the timer starts when the encapsulation starts. \\ \hline
**State:** & **Router S** \\ \hline Event: & Recovery of connection on protected interface or control signal or timer. \\ New state: & Init \\ Action: & The router stops encapsulating the protected flow and enters the Init state. \\ \hline
**State:** & **Init** \\ \hline Event: & Receiving a multicast packet and no entry in the multicast routing table. \\ New state: & Router R \\  & The router has received a packet with the multicast address (M-REP add) and does not have a directly connected destination. If the router does not have an entry in its multicast routing table for (source, M-REP add) pair, it creates a new entry with the RPF interface that has first received the multicast packet. The RPF interface is just one. Interfaces other than RPF and with active \\ Action: & PIM-DM, become output interfaces. Received multicast packet is then forwarded to all output interfaces. If the router has a multicast routing table entry for (source, M-REP add) pair and has received a multicast packet on the RPF interface, the packet is forwarded to all PIM-DM output interfaces. \\  & If the router has a multicast routing table entry for (source, M-REP add) pair and has received a multicast packet on the NON-RPF interface, the multicast packet is dropped. \\ \hline
**State:** & **Router R** \\ \hline Event: & Receiving multicast packet and destination is directly connected on an interface. \\ New state: & Router D \\  & The router has received a multicast packet (the multicast address M-REP add is used) and has directly connected destination. Router D is a router that has the original destination directly \\ Action: & connected to one of its interfaces. Multicast header is then removed from the received multicast \\  & packet, which means that packet is decapsulated and returned to its original state. After \\  & decapsulation, the packet is sent out through the interface where the directly connected \\  & destination is located. Interfaces other than the RPF interface will send a Prune message. \\ \hline
**State:** & **Router R, Router D** \\ \hline Event: & Timer expires or control signal \\ New state: & Init \\ Action: & Deletes the entry in the multicast routing table. After this action, mechanism moves to the Init state. \\ \hline
**State:** & **Router R, Router D** \\ \hline Event: & Loss of connectivity on an RPF interface. \\ New state: & Init \\ Action: & Deletes the entry in the multicast routing table and move to the Init state. \\ \hline \hline \end{tabular}
\end{table}
Table 3: States of the M-REP mechanism.