# Secrecy Control of Wireless Networks with Finite Encoding Blocklength
## 3 Control with Finite Secrecy Codewords
### Algorithm Performance  
Using the Theorem of Lyapunov penalty and drift [22], we can also prove that the proposed control algorithm can close to the optimal arbitrarily. Let \(\mathbf{Q}^{p}(t)=(Q_{1}^{p,c}(t),\ldots,Q_{n}^{p,c}(t))\) denote the queue vector of the first queue in Figure 2, \(\mathbf{P}_{n}(t)=(P_{1}^{c}(t),\ldots,P_{n}^{c}(t))\) be the queue vector of the second queue in Figure 2, \(\mathbf{Q}^{n}(t)=(Q_{1}^{n,c}(t),\ldots,Q_{i}^{n,c}(t))\) represent the queue vector of intermediate nodes for flow \(c\), \(\mathbf{Z}^{n}(t)=(Z_{1}^{n,c}(t),\ldots,Z_{e}^{n,c}(t))\) be the queue vector of leaked confidential message accumulated by eavesdropper and \(\mathbf{Y}_{n}^{k}=(Y_{1}^{k,c},\ldots,Y_{e}^{k,c}(t))\) be the queue vector of secrecy outage. All the queue vectors can be denoted as \(\mathbf{\Theta}(t)\triangleq\left(\mathbf{Q}^{p}(t),\mathbf{P}_{n}(t), \mathbf{Q}^{n}(t),\mathbf{Z}^{n}(t),\mathbf{Y}_{n}^{k}\right)\). Define a Lyapunov function as  
\[ \begin{split} L(\mathbf{\Theta}(t))&\triangleq L \left(\mathbf{Q}^{p}(t),\mathbf{P}_{n}(t),\mathbf{Q}^{n}(t),\mathbf{Z}^{n}(t ),\mathbf{Y}_{n}^{k}\right)\\ &=\frac{1}{2}\sum_{n}\bigg{[}(Q_{n}^{p,c}(t))^{2}+(P_{n}^{c}(t))^ {2}+(Q_{i}^{n,c}(t))^{2}+(Z_{e}^{n,c}(t))^{2}+(Y_{n}^{k,c})^{2}\bigg{]}.\end{split}  \tag{16}\]  
Observing the state of all queues, we have the conditional expectation of on-step queuing evolutions, i.e., Lyapunov drift is:  
\[\Delta(\mathbf{\Theta}(t))=\mathbb{E}\left[L(\mathbf{\Theta}(t+1))-L(\mathbf{ \Theta}(t))|\mathbf{\Theta}(t)\right]. \tag{17}\]  
Substituting the evolution expressions of all queues, we obtain the upper bound of Lyapunov drift is:  
\[ \begin{split}&\Delta(\mathbf{\Theta}(t))\leq B-\sum_{n}\mathbb{E }\left[Q_{n}^{p,c}(t)\left(R_{n}^{p,cs}(t)-NR_{n}^{k_{n}(t+1),cs}\right) \right]-\\ &\sum_{n}\sum_{i\
eq n}\mathbb{E}\left[Q_{i}^{n,c}(t)\left(\sum_{ j|(j,i)\in L}u_{ji}^{n}(t)-\sum_{j|(ij)\in L}u_{ij}^{n}(t)\right)|\mathbf{Q}^{n}(t) \right]\\ &-\sum_{n}\sum_{e}\mathbb{E}\left[NR_{n}Z_{e}^{n,c}(t)\left(R_{n} ^{k_{n}(t),cs}-R_{n}^{k_{n}(t+1),cs}\right)|\mathbf{Z}^{n}(t)\right]\\ &-\sum_{k}\mathbb{E}\left[Y_{n}^{k,c}(R_{n}^{k,cs}-\gamma_{n}R_{n }^{k,cs})|\mathbf{Y}_{n}^{k}\right].\end{split}  \tag{18}\]  
Since the maximum transmission power is finite, all the rates of the network would be bounded. Additionally, the arrival rate \(\lambda_{n}^{max}\) is also bounded. Hence, the parameter \(B\) is a nonnegative constant. Let the Lyapunov drift minus \(V\mathbb{E}\left[\sum_{n,c}U(\bar{R}_{n}^{p,cs})|\mathbf{\Theta}(t)\right]\), where \(V\) is a weight parameter, we obtain the Lyapunov drift and penalty equation:  
\[\Delta^{U}(\mathbf{\Theta}(t))\triangleq\Delta(\mathbf{\Theta}(t))-V\mathbb{E}\left[ \sum_{n,c}U(\bar{R}_{n}^{p,cs})|\mathbf{\Theta}(t)\right]. \tag{19}\]  
According to the Lyapunov optimization theorem [22] and substituting (18) to (19), the upper bound of \(\Delta^{U}(\mathbf{\Theta}(t))\) can be expressed as:  
\[ \begin{split}\Delta^{U}(\mathbf{\Theta}(t))&\leq B- \sum_{n}\mathbb{E}\left[Q_{n}^{p,c}(t)\left(R_{n}^{p,cs}(t)-NR_{n}^{k_{n}(t+1), cs}\right)\right]-\\ &\sum_{n}\sum_{i\
eq n}\mathbb{E}\left[Q_{i}^{n,c}(t)\left(\sum_{ j|(j)\in L}u_{ji}^{n}(t)-\sum_{j|(i,j)\in L}u_{ji}^{n}(t)\right)|\mathbf{\mathbf{Q}}^{n} (t)\right]\\ &-\sum_{n}\sum_{e}\mathbb{E}\left[NR_{n}Z_{e}^{n,c}(t)\left(R_{n }^{k_{n}(t),cs}-R_{n}^{k_{n}(t+1),cs}\right)|\mathbf{\mathbf{Z}}^{n}(t)\right]\\ &-\sum_{k}\mathbb{E}\left[\gamma_{n}^{k,c}(R_{n}^{k,cs}-\gamma_{ n}R_{n}^{k,cs})|\mathbf{\mathbf{Y}}_{n}^{k}\right]-V\mathbb{E}\left[\sum_{n,c}U( \bar{R}_{n}^{p,cs})|\mathbf{\Theta}(t)\right]\ \ (RHS).\end{split}  \tag{20}\]  
Rearranging and observing the \(RHS\) of (20), we find that the MSCAFB algorithm indeed minimizes the right hand side of (20). If the arrival rates of each node are in the feasible region, based on the work in [22], there must exist a stationary scheduling, flow control and end-to-end encoding policy, which select the users and link rates independent of queue length and only relate to the channel statistics.