# End to End Delay and Energy Consumption in a Two Tier Cluster Hierarchical Wireless Sensor Networks
## 7 End-To-End Delay Analysis
### Delay of a Tagged Data Packet  
We defined the mean sojourn time of a given tagged data packet as the time interval elapsed from the instant it is generated until it is delivered to the sink. For example, let \(\overline{W}^{L}_{\langle 3,5\rangle_{p}}\) denote the sojourn time of a data packet from the moment it is generated by a mode in cluster \(\langle 3,5\rangle_{p}\) until it reaches the sink (\(L\) stand from local). For example, let us consider the CHs that belong to the set \(R_{3}\cap(A_{1}\cup S_{1}\cup A_{2})\) (here ring 3 =\(R_{3}\), axes 1, 2 and sector 1), i.e., \(\langle 3,3\rangle_{p},\langle 3,4\rangle_{p},\langle 3,5\rangle_{p},\langle 3,6 \rangle_{p}\), see Figure 4. In vector--matrix notation, we have,  
\[\left[ \begin{array}{c}\overline{W}_{\langle 3,6\rangle}^{L}\\ \overline{W}_{\langle 3,5\rangle}^{L}\\ \overline{W}_{\langle 3,4\rangle}^{L}\\ \overline{W}_{\langle 3,3\rangle}^{L}\end{array} \right]_{p}=\left[ \begin{array}{c}\overline{AC}_{\langle 3,6\rangle}\\ \overline{AC}_{\langle 3,5\rangle}\\ \overline{AC}_{\langle 3,4\rangle}\\ \overline{AC}_{\langle 3,3\rangle}\end{array} \right]_{p}+\left[ \begin{array}{c}CT_{\langle 3,6\rangle}\\ CT_{\langle 3,5\rangle}\\ CT_{\langle 3,4\rangle}\\ CT_{\langle 3,3\rangle}\end{array} \right]_{p}+\left[ \begin{array}{c} \overline{RW}_{\langle 3,6\rangle}\\ \overline{RW}_{\langle 3,5\rangle}\\ \overline{RW}_{\langle 3,4\rangle}\\ \overline{RW}_{\langle 3,3\rangle}\end{array} \right]_{p} \tag{24}\]  
In a compact way we write previous equation as,  
\[\mathbf{W}_{1,1,2}^{L}(3)=\mathbf{AC}_{1,1,2}(3)+\mathbf{CT}_{1,1,2}(3)+ \mathbf{RW}_{1,1,2}(3) \tag{25}\]  
with the short notation, \(A_{1},S_{1},A_{2}=1,1,2\), and \(R_{3}=3\). In Equation (24), \(\overline{AC}_{\langle i,j\rangle_{p}}\), refers to the delay of our packet in the contention process at CH \(\langle i,j\rangle_{p}\). \(CT_{\langle i,j\rangle_{p}}\), accounts for the number of mini-slots between the end of the successful slot \(\mathcal{C}\) (mode \(\mathcal{C}\)) and the end of the first available slot \(\mathcal{T}\) (mode \(\mathcal{T}\)) in the TDMA sub-frame; see Table 4, fourth column where \(CT_{\langle i,j\rangle_{p}}\) is expressed in number of slots. In addition, \(\overline{RW}_{\langle i,j\rangle_{p}}\) is the remaining sojourn time to reaches the sink; in other words, \(\overline{RW}_{\langle i,j\rangle_{p}}\) is the elapsed time between the end of the first available transmission slot \(\mathcal{T}\) in CH \(\langle i,j\rangle_{p}\) until our packet reaches the sink. In vector-matrix notation, \(\overline{RW}_{\langle i,j\rangle_{p}}\) is expressed as,  
\[\left[ \begin{array}{c}\overline{RW}_{\langle 3,6\rangle}\\ \overline{RW}_{\langle 3,5\rangle}\\ \overline{RW}_{\langle 3,4\rangle}\\ \overline{RW}_{\langle 3,3\rangle}\end{array} \right]_{p}=\left[ \begin{array}{c}\overline{W}_{\langle 3,6\rangle}^{\prime}\\ \overline{W}_{\langle 3,5\rangle}^{\prime}\\ \overline{W}_{\langle 3,4\rangle}^{\prime}\\ \overline{W}_{\langle 3,3\rangle}^{\prime}\end{array} \right]_{p}+\mathbf{P} \mathbf{E}_{1,1,2}(3)\left[ \begin{array}{c}TT_{\langle 3,6\rangle,\langle 2,4\rangle}\\ TT_{\langle 3,5\rangle,\langle 2,4\rangle}\\ TT_{\langle 3,5\rangle,\langle 2,3\rangle}\\ TT_{\langle 3,4\rangle,\langle 2,3\rangle}\\ TT_{\langle 3,4\rangle,\langle 2,2\rangle}\\ TT_{\langle 3,3\rangle,\langle 2,2\rangle}\end{array} \right]_{p}+\mathbf{P}_{1,1,2}(3) \left[ \begin{array}{c}\overline{RW}_{\langle 2,4\rangle}\\ \overline{RW}_{\langle 2,3\rangle}\\ \overline{RW}_{\langle 2,2\rangle}\end{array} \right]_{p} \tag{26}\]  
and writing previous expression in a compact way,  
\[\mathbf{RW}_{1,1,2}(3)=\mathbf{W}_{1,1,2}^{r}(3)+\mathbf{P}\mathbf{E}_{1,1,2}(3) \mathbf{T}\mathbf{\Gamma}_{1,1,2}(3)+\mathbf{P}_{1,1,2}(3)\mathbf{RW}_{1,1,2}(2) \tag{27}\]  
In Equation (27), \(\mathbf{P}\mathbf{E}_{1,1,2}(3)\) (stands from matrix P Extended) takes into account the routing probabilities between two neighboring sets of CH, in our example \(R_{3}\cap(A_{1}\cup S_{1}\cup A_{2})\to R_{2}\cap(A_{1}\cup S_{1}\cup A_{2})\).