# Secrecy Control of Wireless Networks with Finite Encoding Blocklength
## 3 Control with Finite Secrecy Codewords  
Similar to the control algorithm proposed in [23], we exploit the Lyapunov penalty and drift to solve this problem. However, due to the secrecy codeword finite and secrecy outage occurrence, the queue model needs to be improved. In particular, as shown in Figure 2, source node is equipped with two separate queues which are operated at two different time scales. The first queue stores the message admitted into the network and \(Q_{n}^{p,c}(t)\) denotes the queue length in slot \(t\). Let \(R_{n}^{p,cs}(t)\) be the admitted confidential message in slot \(t\), which is transmitted from source node \(n\) to destination node \(c\). \(\tilde{R}_{n}^{p,cs}\) represents the long-term average admitted confidential message. The departure of the first queue occurs only when a new secrecy codeword is generated in slot \(t\). Let \(k_{n}(t)\) be the number of secrecy codewords generated in slot \(t\), and \(R_{n}^{k_{n}(t),cs}\) denote the confidential message encoded in \(k_{n}(t)\)-th secrecy codeword. Since there are \(N\) channels, where \(N<\infty\), the actual transmitted confidential message is \(NR_{n}^{k_{n}(t),cs}\) and the length of secrecy codeword is \(NR_{n}^{c}\), the second queue is a partial queue and let \(P_{n}^{c}(t)\) denote the queue length. In this queue, the data departures or not is depended the scheduling and routing policy. Only when the queue is empty, i.e., \(P_{n}^{c}(t)=0\), a new secrecy codeword is allowed to admit into the queue. Thus, we have, if \(P_{n}^{c}(t)=0\), \(k_{n}(t+1)=k_{n}(t)+1\). According to the queue models defined above, the evolution of queues can be expressed as:  
\[Q_{n}^{p,c}(t+1)= \begin{cases}\left[Q_{n}^{p,c}(t)-NR_{n}^{k_{n}(t+1),cs} \right]^{+}+R_{n}^{p,cs}(t)&\text{if }\ P_{n}^{c}(t)=0.\\ Q_{n}^{p,c}(t)+R_{n}^{p,cs}(t)&\text{else}\end{cases}  \tag{7}\]  
\[P_{n}^{c}(t+1)= \begin{cases}NR_{n}^{c}&\text{if }\ P_{n}^{c}(t)=0.\\ \left[P_{n}^{c}(t)-\sum_{i|(n,i)\in L}\mu_{ii}^{n}(t)\right]^{+}&\text{else} \end{cases}  \tag{8}\]  
For each intermediate node, there exists a queue to store the packet from source node \(n\) to destination node \(c\). Let \(Q_{i}^{n,c}(t)\) be the queue length. Then we have  
\[Q_{i}^{n,c}(t+1)=\left[Q_{i}^{n,c}(t)-\sum_{j|(i,j)\in L}\mu_{ij}^{n}(t) \right]^{+}+\sum_{j|(j,j)\in L}\mu_{ji}^{n}(t). \tag{9}\]  
To evaluate the state of secrecy outage, we assume source node \(n\) can perceive the accumulated of confidential message at each eavesdropper, since it can check if some eavesdropper has intercepted  
Figure 2: Queues of source nodes for finite secrecy codewords. the transmission. If it is impossible to know the information precisely, we will discuss in Section 4. Let \(Z_{e}^{n,c}(t)\) denote the number of bits that must be accumulated by eavesdropper \(e\) in slot \(t\) to decode the \(k_{n}(t)\)-th confidential message. Note that, for any eavesdroppers \(e\), if \(Z_{e}^{n,c}(t)=0\), then secrecy outage of the \(k_{n}(t)\)-th confidential message is occurred. Let \(\tilde{R}^{e}(t)\) be the maximum rate that eavesdropper can be achieved, then the evolution of queue \(Z_{e}^{n,c}(t)\) can be denoted as  
\[Z_{e}^{n,c}(t+1)= \begin{cases}\left(R_{n}^{c}-R_{n}^{k_{n}(t+1),cs}\right)N& \text{if }P_{n}^{c}(t)=0.\\ \left[Z_{e}^{n,c}(t)-\tilde{R}^{e}(t)\right]^{+}&\text{else}\end{cases}  \tag{10}\]  
For the constraint (6), a virtual queue \(Y_{n}^{k,c}\) is constructed, which is employed to record the state of secrecy outage. Thus, if the \(k\)-th confidential message is secrecy outage, then the arrival rate of queue \(Y_{n}^{k,c}\) is \(R_{n}^{k,cs}\), else it is \(0\). The evolution of queue \(Y_{n}^{k,c}\) is:  
\[Y_{n}^{k+1,c}(t+1)= \begin{cases}\left[Y_{n}^{k,c}(t)+R_{n}^{k,cs}-\gamma_{n}R_ {n}^{k,cs}\right]^{+}&\text{if k-th message is outage.}\\ \left[Y_{n}^{k,c}(t)-\gamma_{n}R_{n}^{k,cs}\right]^{+}&\text{else}\end{cases}