# Minimization of Average Peak Age of Information for Timely Status Updates in Two-Hop IoT Networks
## 4 Average PAoI Analysis  
In this section, we derive a closed-form formula for the average PAoI. For the analysis, we consider sensor \((g,k)\) as a tagged sensor and track its behavior. For any given time instant \(t\) (\(\geq 0\)), let \(U_{(g,k)}(t)\) denote the generation time of the most recently successfully decoded status packet of sensor \((g,k)\) at the edge server. Then,  
\[\Delta_{(g,k)}(t):=t-U_{(g,k)}(t)\]  
represents the instantaneous AoI of sensor \((g,k)\) at time \(t\)[3]. Whenever the status packet of sensor \((g,k)\) is successfully decoded at the edge server, the AoI is reset to the sojourn time of this packet, given by  
\[T_{(g,k)}=(K-k+1)T_{1}+T_{2}. \tag{4}\]  
Here, the first term represents the time required for the sink node to collect all status packets from the \(k\)-th to the \(K\)-th sensors in group \(g\) during the first-hop transmissions; the second term represents the time needed for the sink node to transmit the jointly coded packet of group \(g\) to the edge server during the second-hop transmission. Once the AoI \(\Delta_{(g,k)}(t)\) is reset to \(T_{(g,k)}\), it increases linearly with a slope of 1 until the next successful decoding of a status packet from sensor \((g,k)\) at the edge server. As a result, the AoI \(\Delta_{(g,k)}(t)\) reaches its local peak just before every successful decoding of a status packet from sensor \((g,k)\) at the edge server. This local peak is referred to as the PAoI, representing the worst-case AoI performance. Let \(A_{(g,k)}^{(i)}\) denote the \(i\)-th PAoI of sensor \((g,k)\). Then, we have  
\[A_{(g,k)}^{(i)}=t_{(g,k)}^{(i)}-t_{(g,k)}^{(i-1)}+T_{(g,k)}, \tag{5}\]  
where \(t_{(g,k)}^{(i)}\) and \(t_{(g,k)}^{(i-1)}\) denote the generation times of the \(i\)-th and \((i-1)\)-th successfully decoded status packets, respectively, of sensor \((g,k)\) at the edge server, and \(T_{(g,k)}\) is given in (4). Figure 2 shows a sample path of \(\Delta_{(g,k)}(t)\). The term \(t_{(g,k)}^{(i)}-t_{(g,k)}^{(i-1)}\) in (5) is probabilistically determined as follows: (i) Sensor \((g,k)\) generates its status packets periodically with a period of \(T_{\text{round}}\), as given in (3). (ii) The decoding of each status packet at the edge server is successful with probability \(p_{s}\) or fails with probability \(1-p_{s}\), where \(p_{s}\) is given in (2). (iii) These decoding outcomes are independent across the status packets of sensor \((g,k)\). From (i) and (ii), it follows that  
\[t_{(g,k)}^{(i)}-t_{(g,k)}^{(i-1)}=T_{\text{round}}\cdot\Big{(}X_{(g,k)}^{(i)}+ 1\Big{)}, \tag{6}\]  
where \(X_{(g,k)}^{(i)}\) is a random variable representing the total number of status packets generated by sensor \((g,k)\) between \(t_{(g,k)}^{(i-1)}\) and \(t_{(g,k)}^{(i)}\) that fail to decode at the edge server. Furthermore, from (ii) and (iii), this random variable follows a geometric distribution with parameter \(p_{s}\) and support \(\{0,1,2,\ldots\}\). Specifically,  
\[\text{P}\Big{(}X_{(g,k)}^{(i)}=j\Big{)}=(1-p_{s})^{j}p_{s},\qquad j=0,1,2,\ldots. \tag{7}\]  
Substituting (6) into (5), we obtain  
\[A_{(g,k)}^{(i)}=T_{\text{round}}\cdot\Big{(}X_{(g,k)}^{(i)}+1\Big{)}+T_{(g,k)}. \tag{8}\]  
Figure 2: A sample path of the instantaneous AoI \(\Delta_{(g,k)}(t)\) over time \(t\). The average PAoI of sensor \((g,k)\), denoted by \(\bar{A}_{(g,k)}\), is expressed as ([30], Equation (5))  
\[\bar{A}_{(g,k)}=\lim_{j\to\infty}\frac{1}{j}\sum_{i=1}^{J}A_{(g,k)}^{(i)}.\]  
Using the expression for \(A_{(g,k)}^{(i)}\) in (8), we obtain  
\[\bar{A}_{(g,k)} \stackrel{{(a)}}{{=}}T_{\text{round}}\cdot\left(\lim _{j\to\infty}\frac{1}{j}\sum_{i=1}^{J}X_{(g,k)}^{(i)}+1\right)+T_{(g,k)}\] \[\stackrel{{(b)}}{{=}}T_{\text{round}}\cdot\left(E[X_ {(g,k)}^{(i)}]+1\right)+T_{(g,k)}.\]  
Here, \((a)\) holds because \(T_{\text{round}}\) and \(T_{(g,k)}\) are independent of \(i\), and \((b)\) follows from the law of large numbers, as \(X_{(g,k)}^{(i)}\) for \(i=1,2,3,\ldots\) are independent and identically distributed random variables.