# Buffer with N Policy and Active Management
## 4 Analysis
Let \(\bar{P}\) denote the expected value of \(P\) (i.e., the expected duration of the energy-saving phase), \(\bar{R}\) denote the expected value of \(R\) (i.e., the expected length of the transmission phase), and \(\bar{C}\) denote the expected duration of a cycle. Moreover, let \(D(u)\) denote the distribution function of \(C\) (and thus of any other \(Y_{j}-Y_{j-1}\) as well):  
\[D(u)=\mathbb{P}\{C<u\}. \tag{7}\]  
For any \(k=0,1,\ldots\), conditioning first on \(i\) in \(Y_{i}\leq t<Y_{i+1}\) and on \(u\) in \(Y_{i}=u\), we have the following:  
\[ \begin{array}{rl}\mathbb{P}\{X(t)=k|X(0)=0\}&=\sum\limits_{i=0}^{\infty} \mathbb{P}\{X(t)=k,Y_{i}\leq t<Y_{i+1}|X(0)=0\}\\ &=\sum\limits_{i=0}^{\infty}\int_{0}^{t}\mathbb{P}\{X(t)=k,Y_{i}\leq t<Y_{i+1 }|X(0)=0,Y_{i}=u\}\text{d}D^{i*}(u)\\ &=\sum\limits_{i=0}^{\infty}\int_{0}^{t}\mathbb{P}\{X(t-u)=k,C>t-u|X(0)=0\} \text{d}D^{i*}(u),\end{array}  \tag{8}\]  
where \(D^{i*}(u)\) is the \(i\)-fold convolution of \(D(u)\), i.e. :  
\[D^{0*}(u)=1,\hskip 14.226378 ptD^{i*}(u)=\int_{0}^{u}D^{(i-1)*}(u-v)\text{d}D_{1}( v),\hskip 8.535827 pti\geq 1. \tag{9}\]  
Denote the renewal function as \(G(u)\):  
\[G(u)=\sum\limits_{i=0}^{\infty}D^{i*}(u). \tag{10}\]  
From (8), we obtain the following:  
\[\mathbb{P}\{X(t)=k|X(0)=0\}=\int_{0}^{t}\mathbb{P}\{X(t-u)=k,C>t-u|X(0)=0\} \text{d}G(u). \tag{11}\]  
To derive \(\pi(k)\), we need to calculate the limit as \(t\to\infty\) of expression (11). This limit can be derived by making use of the key renewal theorem ([45], p. 155). Specifically, to apply this theorem, the function \(\mathbb{P}\{X(t)=k,C>t|X(0)=0\}\) must be directly Riemann integrable over \([0,\infty)\) with respect to the variable \(t\), and \(D(u)\) must not be a lattice distribution. As for the latter requirement, \(D(u)\) is obviously continuous here, rather than the lattice, because of the continuous interarrival distribution. Regarding the former requirement, we have the following:  
\[\mathbb{P}\{X(t)=k,C>t|X(0)=0\}\leq\mathbb{P}\{C>t|X(0)=0\})=\overline{C}<\infty. \tag{12}\]  
Hence, the function \(\mathbb{P}\{C>t|X(0)=0\}\) is Riemann integrable. It is also non-decreasing. Therefore, the function \(\mathbb{P}\{X(t)=k,C>t|X(0)=0\}\) must be directly Riemann integrable because it is not greater than \(\mathbb{P}\{C>t|X(0)=0\}\) for every \(t\). Hence, employing the key renewal theorem to (11), we obtain the following:  
\[\pi(k)=\lim\limits_{t\to\infty}\mathbb{P}\{X(t)=k\}=\overline{C}^{-1}\!\!\! \int_{0}^{\infty}\!\!\!\mathbb{P}\{X(t)=k,C>t\}dt. \tag{13}\]  
Then, the second integral of (13) can be split into two integrals in the following way:\[ \begin{array}{l}\int_{0}^{\infty}\mathbb{P}\{X(t)=k,C>t|X(0)=0\}\mathrm{d}t\\ =\int_{0}^{\infty}\mathbb{P}\{X(t)=k,P>t,C>t|X(0)=0\}\mathrm{d}t+\int_{0}^{ \infty}\mathbb{P}\{X(t)=k,P\leq t,C>t|X(0)=0\}\mathrm{d}t\\ =\int_{0}^{\infty}\mathbb{P}\{X(t)=k,P>t|X(0)=0\}\mathrm{d}t+\int_{0}^{\infty} \mathrm{d}t\int_{0}^{t}\mathbb{P}\{X(t){=}k,C>t|P{=}u,X(0){=}0\}\mathrm{d} \mathbb{P}\{P<u\}.\end{array}  \tag{14}\]  
Moreover, the second integral of (14) can be further simplified as follows:  
\[ \begin{array}{l}\int_{0}^{\infty}\mathrm{d}t\int_{0}^{t}\mathbb{P}\{X(t)=k, C>t|P=u,X(0)=0\}\mathrm{d}\mathbb{P}\{P<u\}\\ =\int_{0}^{\infty}\mathrm{d}t\int_{0}^{t}\mathbb{P}\{X(t-u)=k,R>t-u|X(0)=k\} \mathrm{d}\mathbb{P}\{P<u\}\\ =\int_{0}^{\infty}\mathbb{P}\{X(t)=k,R>t|X(0)=K\}\mathrm{d}t.\end{array}  \tag{15}\]  
The regeneration property of times \(Y_{i}\) and \(Z_{i}\) yields the following:  
\[\overline{C}=\overline{P}+\overline{R}. \tag{16}\]  
Finally, combining together (13)-(16), we obtain the following:  
\[\pi(k)=\frac{A(k)+B(k)}{\overline{P}+\overline{R}},\quad k=0,1,\ldots,N, \tag{17}\]  
where  
\[A(k)=\int_{0}^{\infty}\mathbb{P}\{X(t)=k,P>t|X(0)=0\}\mathrm{d}t, \tag{18}\]  
\[B(k)=\int_{0}^{\infty}\mathbb{P}\{X(t)=k,R>t|X(0)=K\}\mathrm{d}t. \tag{19}\]  
As we can see, (17) constitutes a general formula on the queue length distribution.