# Low-Cost Software Evaluation of Communication Delays in Networked Industrial Systems
## 4 Delay Measurement
### Delay Measurement Technique  
Table 1 summarizes the notation used in the following part of the paper. Let \(u_{X}(t)\) be the value of the timestamp counter of a generic port \(X\) at time \(t\), where \(t\) is a global, absolute time reference. Then,  
\[c_{X}(t)=u_{X}(t)-t \tag{1}\]  
represents the offset of the timestamp counter of port \(X\) with respect to global time, at time \(t\). In general, \(c_{X}(t)\
eq c_{X^{\prime}}(t)\) when \(X\
eq X^{\prime}\) for the reasons mentioned above. Instead, assuming that no port resets occur after initialization  
\[c_{X}(t)=c_{X}\;\;\forall t. \tag{2}\]  
Considering a packet \(p\), the total delay \(\delta\) it incurs when going through the measurement network is given by  
\[\delta=t_{R}-t_{S}, \tag{3}\]  
where \(t_{S}\) is the time at which \(p\) leaves port \(n_{S}\) and \(t_{R}\) is the time when it reaches port \(n_{R}\) (see the configuration \(\mathcal{T}_{DUT}\) in the lower half of Figure 2). \(t_{S}\) cannot be accurately determined in general. However, \(\mathit{TAP}\) and \(n_{M}\) help in overcoming this limit. In fact, short-circuiting packets sent by \(n_{S}\) to \(n_{M}\) through \(\mathit{TAP}\) brings the following two main advantages:  
1. Outgoing packets can be timestamped accurately, because they are mirrored into \(n_{M}\)'s receive path, where the I350 has no timestamping constraints. 2. \(\mathit{TM}\) no longer performs any measurement involving \(n_{S}\), and becomes completely independent from the packet generator, which could then even be hosted on a different network node. \begin{table}
\begin{tabular}{c l} \hline \hline
**Symbol** & **Definition** \\ \hline \(u_{X}(t)\) & Timestamp counter of port \(X\) at time \(t\) \\ \(c_{X}\) & Time-independent offset of \(u_{X}(t)\) with respect to \(t\) \\ \(t_{X}\) & Transit time of a packet \(p\) through port \(n_{X}\) \\ \(\delta\) & Delay incurred by \(p\) through the measurement network \\ \(\delta_{Y}\) & Delay introduced by device \(Y\) \\ \(\omega\) & Nominal inter-packet interval \\ \(X_{\omega}\) & Random sample of population \(\omega\) \\ \(m_{\omega}\) & Number of samples in \(X_{\omega}\) \\ \(X_{\omega}\) & Sample mean of \(X_{\omega}\) \\ \(s_{\omega}^{2}\) & Sample variance of \(X_{\omega}\) \\ \(l\) & Ethernet packet length (incl. CRC; excl. preamble, SFD, IPG) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Notation used in the paper. The first advantage broadens the range of network controller cards _TM_ can use, because it simplifies the requirements they must satisfy. The second one makes _TM_ more general because it can accommodate external traffic generators without changing the measurement technique. Completely automatic tests are still possible too, provided those generators support some form of remote management. At the same time, adding _TAP_ to the measurement path does not have any adverse side effect because it introduces the same, fixed delay \(\delta_{\textit{TAP}}\) along both the \(n_{S}\longrightarrow n_{SW}^{S}\) and \(n_{S}\longrightarrow n_{M}\) paths. In this way the arrival of the packet at \(n_{M}\) still accurately reflects the time at which the same packet enters \(SW\) at its \(n_{SW}^{S}\) port and we can write the following:  
\[\delta=(t_{R}-t_{M})+(t_{M}-t_{S})=t_{R}-t_{M}+\delta_{\textit{TAP}}, \tag{4}\]  
which expresses \(\delta\) in terms of quantities that can be measured. Moreover, the _TM_ calibration technique discussed in the following and based on differential delay measurement with/without DUT, makes \(\delta_{\textit{TAP}}\) irrelevant for DUT delay calculation, provided it is fixed. Specializing (1) for ports \(n_{R}\) and \(n_{M}\) at \(t_{R}\) and \(t_{M}\), respectively, and taking (2) into account, we can write the following:  
\[t_{R}=u_{R}(t_{R})-c_{R},\;\;t_{M}=u_{M}(t_{M})-c_{M}. \tag{5}\]  
Substituting (5) into (4) we obtain  
\[ \begin{split}\delta&=(u_{R}(t_{R})-c_{R})-(u_{M}(t _{M})-c_{M})+\delta_{\textit{TAP}}\\ &=u_{R}(t_{R})-u_{M}(t_{M})-(c_{R}-c_{M})+\delta_{\textit{TAP}}. \end{split}