# Quantum Key Distribution in Kubernetes Clusters
## 3 Quantum Software Stack 2.0
### Routing  
We introduced the _Routing Module_ (RM) to allow proper traffic steering within a QKD network and connect two arbitrary endpoints (SAEs) supporting long-distance QKD exchanges. From a high-level perspective, each QKS has its own RM, which shares routing information with its peers in the network, enabling the QKS to establish whether an SAE is reachable and the best path to arrive at it. The RM leverages a modified version of the _Open Shortest Path First (OSPF)_ protocol [23] to select the best path, an approach similar to the one adopted by DARPA and SECOQC in [24; 25]. Information such as SAEs reachable from a specific QKS and recently opened Ks are transmitted, sending _Link State Advertisements_ (_LSAs_). The sending of an LSA is triggered on specific events: registration or removal of a new SAE, opening a new KS, and expiration of the internal RM timer. This timer is required to tackle situations where the signalling mechanism fails, i.e., when a node is no longer reachable from the network and routing tables still need to be updated. The RM stores the collected information in a Redis data structure, as we depicted in Table 1.  
The communication among RMs takes place by leveraging a TCP connection and custom packets whose structure is shown in Table 2. There exist two packet types so far: the S packet, which carries information regarding the SAE on a specific QKS and is typically sent after an SAE registration, and the packet K, which holds information on the QKS neighbours and the costs to reach them. The routing protocol computes the routing tables using the Dijkstra algorithm, and the cost function \(C(t)\) is defined by Equation (1), where \(\mathbb{P}\) is the set containing all the links of a chosen path. \[C(t)=\sum_{i}K_{i}(t)\qquad\forall i\in\mathbb{P}. \tag{1}\]  
\(K_{i}(t)\) is the key load and is defined by the Equation (2). It represents the cost of a single link based on the available keys on that link at the time \(t\) and \(t-1\). The coefficient \(c_{0}\) represents the cost when no key is available. This cost is mitigated by the second term in which \(K\) represents the total number of keys that the buffer could contain and \(k_{i}(t)\) is \begin{table}
\begin{tabular}{c c c} \hline \hline
**Name** & **Type** & **Description** \\ \hline SAE\_ID & String & name used to identify the destination SAE \\ next\_hop & String & ID of the next QKS in the path to the destination SAE \\ dest & String & ID of the QKS of the destination SAE \\ cost & Integer & the cost \(C(t)\) associated to the path from the current SAE to the destination \\ length & Integer & number of nodes in the path to reach the destination \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Description of the routing table entries in Redis. the number of the currently available keys at the time \(t\). The more \(k_{i}(t)\) grows, the more this term decreases the key load. The third term models the tendency of \(k_{i}(t)\) to increase or decrease over time. Since the only available information as a metric is related to the available keys and no Quality-of-Service (QoS) parameter (e.g., error rate, jitter) is known, this is an attempt to model other cost contributions such as congestion on a specific link. The weights \(w_{1}\) and \(w_{2}\) allow the balance of the contribution of each term. \[K_{i}(t)=c_{0}-w_{1}\cdot\frac{k_{i}(t)}{K}-w_{2}\cdot\frac{k_{i}(t)-k_{i}(t-1) }{K}. \tag{2}\]  
The RM allows the management of the routing within a QKD network, making each QSS independent from the others. Other strategies, like the ones based on SDN [17], offer advantages such as the centralised management of the whole network by knowing a priori its topology. They could also consistently reduce the number of packets exchanged among RMs, thus minimising the requirement for additional key material (all routing packets need authentication). On the bright side, with our decentralised solution, no central entity (e.g. SDN controller) has to have, even if partial, access to the QSSs.