# End-to-End Delay Model for Train Messaging over Public Land Mobile Networks
## 4 Proposed E2E Delay Model
### E2E Delay Model  
The proposed E2E delay model relates the receive time \(R_{i}\) of the generic \(i\)-th message with the corresponding transmit time \(T_{i}\) as:  
\[R_{i}=T_{i}+\tau_{i},\quad i=-\infty,\ldots,+\infty, \tag{2}\]  
where \(\tau_{i}\) is the E2E delay. The proposed model allows for generating the stochastic process \(\{\tau_{i}\}\) modeling the occurrence of the events discussed in the previous section. The E2E delay \(\tau_{i}\) for the \(i\)-th transmitted message is generated in accordance with the two states model in Figure 7.  
The operations of the two states diagram are detailed in the pseudo-code reported in the following listing:  
1. Initialize the message generation counter \(i=1\);
2. Set initial channel state variable to \(G\) i.e., \(state=G\);
3. Start E2E delay calculation for each time instant \(t_{i}=i\Delta T\) (\(\Delta T\) is the lowest time interval considered for the generation of messages);
4. If \(state==G\),  
* For a given position of the train along the line, the received power and the serving radio technology, generate one sample of the random variable \(X_{0}\) (the statistic of \(X_{0}\) will be detailed in the following of this section) accounting for (possible) handover situation as follows:
* if Handover is OFF, generate \(X_{0}\) in accordance with the statistics of \(X_{0}\) in the non-handover case (see after);  
Figure 6: Time-based representation of buffering (state Q) and direct transmission (state G) conditions in the channel. if Handover is ON, with probability \(p_{H}\), generate \(X_{0}\) in accordance with the statistics of \(X_{0}\) in the handover case (indicated with \(X_{H}\), see after), else generate \(X_{0}\) in accordance with the statistics of \(X_{0}\) in the non-handover case (see after);
* given the generated \(X_{0}\),
* if \(X_{0}<\Delta T\), set \(\gamma_{0}=X_{0}\), set \(\tau_{i}=\gamma_{0}\), \(i=i+1\), \(state=G\);
* if \(X_{0}\geq\Delta T\), set \(\gamma_{0}=X_{0}\), set \(\tau_{i}=\gamma_{0}\), \(i=i+1\), \(state=Q\). 5. if \(state==Q\)  
* For a given position of the train along the line, the received power and the serving radio technology, generate one sample of the random variable \(X_{1}\) (the statistic of \(X_{1}\) will be detailed in the following of this section);
* Calculate \(\gamma_{1}=\gamma_{0}-\Delta T+X_{1}\) (recursion formula);
* Set \(\tau_{i}=\gamma_{1}\), \(i=i+1\);
* Given \(\gamma_{1}\),
* if \(\gamma_{1}-\Delta T<0\) (exit from state Q at the next iteration), set \(state=G\);
* if \(\gamma_{1}-\Delta T\geq 0\), set \(\gamma_{0}=\gamma_{1}\) (stay in state Q for the next iteration and update delay calculation), \(state=Q\). 6. go to 4  
Random variables \(X_{0}\) or \(X_{1}\) are generated every \(\Delta T\) independently of the transmission times of messages from the railway applications. The statistics of \(X_{0}\) and \(X_{1}\) have been differentiated in accordance with the received power level and the selected radio technology. As shown in the two states model diagram in Figure 7, transition from state G to Q is triggered by \(X_{0}\). In particular, when \(X_{0}>\Delta T\), the G to Q transition occurs. This is accounted for in the model by the tails of the statistics of \(X_{0}\), \(X_{H}\) and \(X_{1}\), which are derived in the next section. When the channel is in state Q, its behavior is regulated by the random variable \(X_{1}\). The condition \(X_{1}>\Delta T\) triggers the  
Figure 7: Two states diagram of the proposed E2E delay model. saw-tooth like behavior observed experimentally. The pseudo-code defining the model behavior in state Q implements the following recursive formula:  
\[\tau_{i}=\tau_{i-1}-\Delta T+X_{1}. \tag{3}\]  
This is used to evaluate the E2E delay of the message taking into account the buffering (see Figure 6) in the transmitter. In this figure, the relations between the E2E delays \(\tau_{2}\) and \(\tau_{3}\) with \(\Delta T\) and \(X_{1}\) have been made evident.