# A Dynamic-Routing Algorithm Based on a Virtual Quantum Key Distribution Network
## 3 Routing Algorithms
### Algorithm Evaluation Indicators  
A comparison simulation with the classical Open Shortest Path First routing algorithm (OSPF) and the routing algorithm using the residual key-path-weighted routing algorithm (RKP) is carried out to more comprehensively evaluate and verify the performance of the algorithm proposed in this paper. Taking into account the QKD network characteristics, routing rules, and network quality, the following three evaluation metrics are designed:  
1. Average key utilization. Average critical consumption refers to the resource consumption required to establish and maintain a security key in a dynamic QKD routing method. Dynamic QKD routing methods can utilize resources more efficiently and achieve better system performance by reducing the average key consumption. It reflects the degree to which the allocated vital resources are used within a certain period  
Figure 5: Algorithm optimization design flowchart.  
and then reflects whether the allocation and management of the key are reasonable. The calculation representation is shown in Formula (15): \[C=\frac{Q_{ij}}{R_{ij}}ij\in P_{s,d}\] (15)
2. Blocking rate of key distribution operations. The key distribution blocking rate is the probability of key distribution failure due to channel conditions, network congestion, or other factors in a dynamic QKD routing method. The blocking rate of key distribution directly affects the system availability and the efficiency of key generation. By reducing the blocking rate of key distribution, the dynamic QKD routing method can improve the success rate of key generation, effectively reduce the risk of system interruption, and improve the efficiency of key generation. The key distribution blocking probability can directly reflect the blocking situation and the system performance and is an important index to measure the performance of the QKD system. Assuming the number of blocking service interruptions occurring due to insufficient collection link resources, \(N_{b}\) and \(N_{k}\) denote the total number of service requests. Then, the blocking rate M of the key distribution service is obtained, where the calculation is expressed as follows (16): \[M=\frac{N_{b}}{N_{k}}\] (16)
3. Time delay of the algorithm. The algorithm time delay refers to the time required to compute the optimal routing and key distribution path in the dynamic QKD routing method. This index reflects the response speed and real-time performance of the dynamic QKD routing method. The lower algorithm time delay can enable the dynamic QKD routing method to adapt faster to changes in network topology and alterations in key distribution requirements, thus improving the flexibility and efficiency of the system. In QKD networks, transmission, processing, and waiting delays are usually combined into a total delay. Assuming that the routing algorithm sends data from the source node to the destination node through n intermediate nodes, the total delay of this route is as shown in (17). The average delay per link is (18): \[T_{t}=\sum_{i=1}^{n+1}\left(t_{d}+t_{p}+t_{w}\right)\] (17)  
\[T_{D}=\frac{T_{t}}{N_{r}} \tag{18}\]  
where \(t_{d}\) represents the transmission time between node \(i\) and node \(i+1\), \(t_{p}\) represents the time node \(i\) caches, forwards and processes data, and \(t_{w}\) represents the time node \(i\) waiting for responses from other nodes. \(n+1\) includes the source and destination nodes. Assuming there are \(N_{r}\) links on a path, \(T_{D}\) means the average delay of each link.