## 3 Problem Statement
### Network Model
\begin{table}
\begin{tabular}{c c} \hline \hline
**Notation** & **Definition** \\ \hline \(u\) & The node in the network topology \\ \(V\) & The set of nodes \\ \(r_{k}\) & The service reaching QKDN with key requirements \\ \(R_{k}\) & The set of services reaching QKDN \\ \(s_{r}\) & The source node of service \\ \(d_{r}\) & The destination node of service \\ \(M_{r}\) & The number of secret keys required by the service in unit time \\ \(s_{a}\) & A random node in the network topology \\ \(s_{b}\) & A random node in the network topology different from \(s_{a}\) \\ \(e\) & Number of links from the source node to the destination node \\ \(v\) & Source node of the selected working path \\ \(w\) & Destination node of the selected working path \\ \(x\) & Source node of the selected protection path \\ \(y\) & Destination node of the selected protection path \\ \(l_{a,b}\) & Direct link between two adjacent nodes \\ \(L\) & The set of direct links \\ \(P_{v,w}\) & Working path for the service \\ \(P_{x,y}\) & Protection path for the service \\ \(r_{v,w}\) & The key resource provided by the link for the working path \\ \(T_{x,y}\) & The key resource provided by the link for the protection path \\ \(P\) & The set of calculated paths \\ \(weights\) & The length of the path \\ \(\eta\) & Proportion of key protection threshold in the remaining key \\ resources of the link \\ \(t_{a}\) & The arrival time of the service \\ \(t_{r}\) & The duration of the service \\ \(T_{h}\) & Remaining key resources in each hop on path \\ \(T_{p}\) & Secret key protection threshold \\ \(s_{a}{\rightarrow}s_{b}\) & Number of hops between nodes \(s_{a}\) and \(s_{b}\) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Notation and definitions. ```
Input: network topology \(G(V,L)\), service \(r_{k}(s_{r},d_{r},M_{r},t_{a},t_{r})\), Weights, \(T_{h}\), \(\eta\) Output: dedicated protection for each service
```
1 Traverse and record the trusted and untrusted nodes \(u\) in the network topology
2 for all \(l_{a,b}\) do
3 if\(s_{a}{\rightarrow}s_{b}=1\) and both \(s_{a}\), \(s_{b}\) are untrusted nodes then
4 remove the virtual link corresponding to link \(l_{a,b}\)
5 end if
6 if\(s_{a}{\rightarrow}s_{b}=2\), \(s_{a}{\rightarrow}s_{c}=1\), \(s_{c}{\rightarrow}s_{b}=1\) and \(s_{a}\), \(s_{b}\) are trusted nodes, \(s_{c}\) is untrusted node then
7 forming virtual direct link \(l_{a,b}\)
8 end if
9 end for
10 for all \(r_{k}\in R_{k}\) do
11 Calculate \(e\) paths \(P\)
12 Obtain the lowest Weight path \(P_{o,w}\) from set \(P\)
13 Delete \(P_{o,w}\) in \(P\)
14 if\(T_{e,w}<M_{r}\) and \(P=\mathcal{O}\) then
15 The dedicated protection of \(r_{k}\) failed
16
17 The dedicated protection of \(r_{k}\) failed
18 else mark \(P_{o,w}\) as the working path
19 Obtain the lowest Weight path \(P_{x,y}\) from set \(P\)
20 Delete \(P_{x,y}\) in \(P\)
21 if\((T_{x,y}<M_{r}\) or \(M_{r}>T_{h}\eta)\) and \(P=\mathcal{O}\) then
22 The dedicated protection of \(r_{k}\) failed
23 else mark \(P_{x,y}\) as the protection path
24 end if
25 end if ```  
**Algorithm 1**Topology-abstraction-based protection scheme in QKDN with partially trusted relay. Then there is the process of working path routing and secret key resource allocation. Firstly, when the service request arrives, the basic attributes of the service will be analyzed, such as the source node \(s_{r}\) and destination node \(d_{r}\) of the service, the start time \(t_{a}\) and the duration \(t_{r}\) of the service and the quantum key rate per unit time \(M_{r}\) required by the service. The data of the service are stored in the linked list. Secondly, according to the number of link hops between the source node and the destination node, the _Dijkstra_ algorithm is used to calculate the shortest paths and put them into the path set \(P\). The selected shortest path is temporarily marked as the working path, and the current remaining key resources of each hop route along the temporarily marked path are calculated.