# Functional Safety Networks and Protocols in the Industrial Internet of Things Era
## 4 The Fail Safe over EtherCAT Protocol Implemented on WiFi
### Tests in a Noisier Environment with Additional Transport Layer Protocols  
A further assessment of the FSoE protocol over WiFi was carried out in a noisier environment. Specifically, in this case, the tests were conducted in a laboratory with more people and equipment, where there was no control on the sources of interference. Moreover, two additional strategies were considered at the transport layer. The first one was represented by the use of TCP, whereas the second one still uses UDP but with an additional caching layer inserted between the UDP and the FSoE protocol stacks. We refer to it as \(UDP_{c}\). It has been introduced to specifically handle both duplication and re-transmission of FSoE frames, as the legacy UDP protocol cannot perform such functions. It is worth observing that \(UDP_{c}\) does not imply modifications neither to UDP, nor to FSoE. The caching layer stores both the incoming SPDUs from the UDP protocol stack and the outgoing ones from the FSoE stack. For every outgoing SPDU, the caching layer expects to receive an incoming frame within a predefined deadline \(T_{D}\). In case of packet loss, the deadline expires and the caching layer performs a re-transmission of the outgoing SPDU it previously stored. Notably, the deadline is completely independent on the FSoE watchdog timeout that will continue to monitor autonomously for communication delays. Clearly, to effectively exploit the re-transmission mechanism provided by the caching layer, the following relation must hold  
\[T_{p}\leq T_{D}<WDTout\]  
The handling of duplicate frames is done by exploiting one of the fundamental features of SPDUs. Indeed, FSoE is designed to ensure that two consecutive frames should differ by at least one bit. This is ensured by the use of consecutive sequence numbers as well of CRC. Due to this characteristic, if two identical frames are received, they are certainly duplicated frames. In this situation, the caching layer detects frame duplication simply comparing the received frame with the previously stored incoming frame. The working principle of the caching layer is summarized in Algorithm 1. The results of the experimental campaign are reported in Table 3 (packet loss), Table 4 (polling time statistics) and Figure 6 (polling time empirical PDF). \begin{table}
\begin{tabular}{l c c c} \hline \hline  & \multicolumn{3}{c}{**Polling Time (\(\upmu\)s)**} \\ \hline  & **mean** & **std** & **min** & **max** \\ \hline UDP & 2277.18 & 1113.25 & 1183.89 & 43,128.30 \\ TCP & 2366.40 & 1144.27 & 1257.90 & 225,480.00 \\ UDPc & 2281.71 & 1113.14 & 1187.54 & 51,522.90 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Polling time statistics for different transport layers on IEEE802.11. \begin{table}
\begin{tabular}{l c c c} \hline \hline  & \multicolumn{3}{c}{**Packet Loss**} \\ \hline  & **Total pkt** & **pkt Lost** & **\% pkt Lost** \\ \hline UDP & 7,817,020 & 25 & 0.00032 \\ TCP & 7,457,630 & 1 & 0 \\ UDPc & 7,726,440 & 0 & 0 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Lost FSoE Packet Statistics for different transport layers on IEEE802.11. ```
1 whiletruedo
2 ifhas incoming frame from UIDPthen
3 incomingFrame = ReceiveFsoeFrameFromUdp();
4 ifincomigFrame!= storedIncomingBufferthen
5 reset deadline \(T_{D}\);
6 storedIncomingBuffer = incomingFrame;
7 outcomingFrame = executeFsoeStack(incomingFrame);
8 storedOutcomingBuffer = outcomingFrame;
9
10 else
11 outcomingFrame = storedOutcomingBuffer;
12
13 end if
14 TransmitFsoeFrameToUdp(outcomingFrame);
15
16 else
17 ifdeadline \(T_{D}\) is expiredthen
18 TransmitFsoeFrameToUdp(storedOutcomingBuffer);
19
20 end if
21 update deadline;
22
23 end if
24 update watchdog;
25 ifwatchdog is expiredthen
26 trigger fail safe condition;
27 reset FSoE stack;
28
29
30 end if
```  
**Algorithm 1**Caching layer  
At a first glance, the (negative) effects of the noisier environment appear evident. Indeed, the performance figures of the protocol when UDP is used are worse than in the previous experiments.