## 3 System Model
### Virtual Networking
#### 4.2.2 Route Connection
The nodes in the current k-bucket are selected to enter the k-bucket in the left subtree or the right subtree according to this bit. When the k-bucket splits to the maximum level specified by the system, no more splits will be made. However, if the k-buckets are all unreachable nodes in which this  
Figure 10: The k-bucket of reachable nodes represented using a binary tree. There are three types of nodes in the k-bucket, which are represented by three colors. For clarity of presentation, not all of the 160 bit address space is shown. node directly remains connected, they will not be restricted by this condition. When there are two types of nodes in a k-bucket and the maximum number of split levels has been reached, the node cache with the lowest access frequency will be removed when the directly connected unreachable nodes or node caches are added again. When the number of nodes in a particular k-bucket decreases, the merge operation of the k-bucket will be executed if the merge condition is satisfied. Node joining: As mentioned earlier, the node joins the overlay network by first connecting to the bootstrap node. Then it becomes part of the network by joining to the network through the node. The joining algorithm of nodes is shown in Algorithm 2. ```
Input: A series of bootstrap nodes \(b_{1},b_{2},b_{3},\ldots,b_{n}\in\mathcal{B}\); \(NodeID_{i}\) of node \(n_{i}\) to be accessed Output: node type \(Ntype\); session for unreachable nodes; k-bucket for reachable nodes
1\(n_{i}\) randomly selects a node \(b_{i}\) in \(\mathcal{B}\) and gets in connection with \(b_{i}\)
2\(n_{i}\) opens port \(Prot_{n}\)
3\(b_{i}\) determine whether node \(b_{i}\) is reachable by whether \(IP_{n}:Port_{a}\) is connected or not determine node type \(Ntype\)
4 if\(Ntype\) is a reachable nodethen
5\(addkbucketR(NodeID_{i},IP,Port)\);
6\(Neighbors\gets FindNode(b_{i})\);
7 foreach\(e\) in Neighborsdo
8\(addkbucketR(NodeID_{e},IP,Port)\);
9\(FindNode(b_{i},IP,Port)\);
10
11 end if
12
13 else
14\(Neighbors\gets FindNode(b_{i})\);
15 foreach\(e\) in Neighborsdo
16\(Dis=n_{i}\oplus NodeID_{e}\);
17
18 end if
19\(minNode\gets sub(Neighbors)\);
20
21 The first N nodes with the smallest \(Dis\);
22 foreach\(mn\) in minNodedo
23\(ConnectedLong(mn)\);
24\(addkU(session,NodeID)\);
25
26 end if
27
28 end for return\(Ntype;session;k-bucket\)
```  
**Algorithm 2**Nodes (reachable nodes \(\mathcal{R}\), unreachable nodes \(\mathcal{U}\)) join algorithm  
When node \(n_{i}\) randomly connects to the last bootstrap node \(b_{i}\), the bootstrap node first makes a judgment on the node type of \(n_{i}\), which can be known as \(n_{i}\in\mathcal{R}\) or \(n_{i}\in\mathcal{U}\). If the node type is the reachable node \(c_{i}\), then \(n_{i}\) needs to join the routing network and participate in the construction of the routing table of the whole network. Firstly, it inserts its own node into its own k-bucket, as shown in Figure 10 for node \(0\). Then execute \(FindNode\) operation of the Kademlia algorithm to update its own k-bucket according to the received information. Then these nodes are queried sequentially from near to far. In this way, while constructing its own routing table, it also inserts its information into the routing table of the neighboring nodes. If the node type is unreachable node \(r_{i}\), then \(n_{i}\) does not need to be added to the routing network and does not participate in the construction of the routing table for the whole network. First, the \(FindNode\) operation is executed to extract the N nodes with the smallest logical distance from its own based on the received information. Then connections are established with each of these N nodes to make these nodes aware of their own information and add them to the k-bucket. Subsequently, these connections need to be continuously maintained. Node joining is a dynamic process where nodes need to do some operations cyclically after joining to the network to ensure their own availability and that of the whole network.