# Error Recovery in the Time-Triggered Paradigm with FTT-CAN
## 5 Resource Optimization Process
### Building the Interference Patterns  
To build the interference patterns we need first to determine the necessary replication level. The Algorithm 1 calculates the necessary replica number for arbitrary scenarios. This algorithm is based on Equation (14), returning vector _RepLevel_, which contains the number of replicas necessary to obtain a probability of non-recovery below \(p\varepsilon\) for \(i\) errors in the SW.  
For illustration purposes, Algorithm 1 was applied to an FTT-CAN system with a 1 Mbps bit-rate, LEC = 2.5 ms, LSW = 1.25 ms, \(\lambda\) = 0.26 errors per second (Aggressive environment, Table 1) and 15 messages with period 5 ms and size 125 bits. The desired global unreliability level \(\varepsilon_{G}\) was set to \(10^{-9}\), which translates to \(p\varepsilon\approx 10^{-16}\) by applying Equation (7). Table 2 presents the obtained values. The vector returned by Algorithm 1 for the example above is _RepLevel_ = {3, 3, 2, 1}. Then, we have to compute how many errors must be handled in a single SW and also the maximum number of single errors that have to be accommodated in consecutive SWs, which are the two extreme cases (to see this just calculate the scenario probability by applying Equation(5) to all the considered error scenarios). Algorithm 2 computes these values, termed _max_Icycle_ and _max_cycles_, that will be used to build all possible error scenarios. ```
1:\(max\_cycles\) = 0, p,error = 1
2:while(p,error > p) do  max_cycles = max_cycles + 1 \(p\_error\) = P\({}_{1}\) (1;LSW) \(max\_cycles\) end_while
3:\(max\_cycles\) = max_cycles - 1
4:\(max\_cycle\) = 0, p_error = 1
5:while(p,error > p) do  max_Icycle = max_Icycle + 1 \(p\_error\) = P\({}_{1}\) (max_Icycle,LSW) end_while
6:\(max\_Icycle\) = max_Icycle - 1
7:returnmax_cycles,max_Icycle
```  
**Algorithm 2**_MaxErrors_: Maximum single consecutive errors and maximum errors in one cycle  
The algorithm accepts as inputs \(LSW\), \(\lambda\) and \(pe\). Lines 1-3 compute the maximum number of consecutive ECs that may be affected by one single error. The reasoning is similar to the one used to derive Equation (14). As in the Poisson process arrivals are independent, the probability of having exactly one error in \(n\) consecutive cycles is given by the product of the probability of having exactly one error in one cycle, given by \(P_{\lambda}\) (\(1\); \(LSW\)). Lines 4-6 compute the maximum number of errors in one \begin{table}
\begin{tabular}{c c c c} \hline \hline \multirow{2}{*}{**Scenario**} & **Replica Number** & \multirow{2}{*}{**Pail**} & \multirow{2}{*}{\(\epsilon_{G}\) = 10\({}^{-9}\)} & **Overhead** \\  & **(n Mgsg)** & & & **(Number Mgsg)** \\ \hline
1 error, triple ret & 3 & \(1.12\times 10^{-17}\) & OK & 3 \\
2 errors, triple ret & 3 & \(3.62\times 10^{-21}\) & OK & 6 \\
3 errors, double ret & 2 & \(1.81\times 10^{-21}\) & OK & 6 \\
4 errors, simple ret & 1 & \(6.04\times 10^{-21}\) & OK & 4 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Number of replicas needed for a target reliability level in an Aggressive environment. SW, being a direct iteration of the Poisson probability function applied to one SW. Table 3 illustrates the results of the algorithm for several scenarios of \(LSW\) and \(\lambda\). One can see that _max_cycles_ and _max_Icycle_ tend to increase with higher values of LSW and \(\lambda\), as expected. After obtaining these two values, we can build the various error sequences or scenarios, _Error_S_, that produce maximum interference. These are the result of all combinations with length _max_cycles_ and a maximum of _max_Icycle_ errors per EC. For instance, if we consider both _max_cycles_ and _max_Icycle_ equal to 3, then the possible error combinations are the ones presented in Figure 7. The horizontal-axis in Figure 7 represents the ECs, while errors with probability greater than \(pe\) are represented by a solid circle. These sequences, when combined with the _RepLevel_ vector, allow for us to build the set of _Interf_P_ required for computing Equation (16), as explained in the next section.