## 3 Network Model
### CPSR-HQ KDN Routing Scheme
\begin{table}
\begin{tabular}{l} \hline Input: t \(\in\) T, l \(\in\) L, n \(\in\) N, p, W \\ Output: optimal path for a Class N Data Packet \\ \hline Routing Algorithm for Class N Data Packets (topo, start, end): \\ weights = [vertex: infinity for vertex in topo] \\ weights[start] = 0 \\ path = \{\} visited = set() \\ while not all(weights[vertex] == infinity for vertex in topo): \\ current\_vertex = min((vertex, weights[vertex]) for vertex in topo - visited)[0] \\ visited\_add(current\_vertex) \\ for neighbor, weight in topo[current\_vertex].items(): \\ if weights[neighbor] \(>\) weights[current\_vertex] + w: \\ weights[neighbor] = weights[current\_vertex] + w \\ path[neighbor] = current\_vertex \\ shortest\_path = [] \\ current\_vertex = end \\ while current\_vertex!= start: \\ shortest\_path.append(current\_vertex) \\ current\_vertex = path[current\_vertex] \\ shortest\_path.append(start) shortest\_path.reverse() \\ return shortest\_path, weights[end] \\ \hline \end{tabular}
\end{table} 
Table 2: Routing Algorithm for Class N Data Packets. Figure 5: Schematic diagram of N-class packet queue insertion. \[SNR_{l,t}\geq\sigma \tag{6}\]  
Due to external interference, such as noise or signal attenuation, the transmission of signals over the physical link, namely the optical fiber, may suffer from significant impairments. This can greatly impact the key update rate and packet transmission success rate. Thus, the controller needs to obtain the signal transmission quality information for both the quantum channel and the public channel in each time slot. Equations (3) and (4) are used to represent the signal transmission quality for the quantum channel and the public channel, respectively, where QBRR denotes the quantum bit transmission error rate, and SNR represents the signal-to-noise ratio. Equations (5) and (6) represent the thresholds below which the allocation of that particular link is abandoned until its signal quality recovers, with \(\rho\) and \(\sigma\) being the respective threshold values. \[kr_{l}\geq p_{kd} \tag{7}\]  
Equation (7) represents that when selecting the path for forwarding, it is also necessary to ensure that the remaining key quantity of the next-hop link is greater than the required key quantity for the data packet. \[\omega=\delta*\frac{\sum_{n}Q_{n}}{p_{n}}+\varepsilon*\frac{p_{n}}{\sum_{n}kr_{ l}},n\in R_{n} \tag{8}\]  
Based on these constraints, the remaining feasible paths are obtained and a final routing scheme is determined based on the remaining key quantity and hop count of each link. Equation (8) represents the calculation of the weights, which are determined by the length of the node port's waiting queue and the remaining key quantity. Here, \(R_{n}\) represents the set of nodes for a specific selectable path, and \(\delta\) and \(\varepsilon\) are two adjustment factors. Table 3 illustrates the routing algorithm for L-class and H-class packets. Firstly, an initial weight matrix for the network topology needs to be constructed. Each element in the initial weight matrix corresponds to a tuple \((l_{c},l_{s},\omega,kr_{l})\). It should be emphasized that the network topology differs between L-class and H-class packets, resulting in different weight matrices depending on the \(l_{c}\) condition. Then, according to Equations (5) and (6), it is determined whether the \(l_{s}\) in the current initial weight matrix meets the forwarding criteria. If it does not meet the criteria, it is set to 0. Subsequently, considering factors such as the number of waiting time slots carried by the packet and the required key quantity, an improved version of the Floyd algorithm is used to select the final path. Additionally, in this scheme, L-class and H-class packets that exceed the threshold of waiting time slots are directly discarded. In the source node, if the forwarded packet exceeds the expected response time, an opportunity for retransmission is provided to improve the quality of service.