## 3 System Model
### Virtual Networking
#### 4.2.3 Peer Discovery for Unreachable Node  
In this section we introduce peer discovery within the overlay network plane, in particular discovery and routing messaging between unreachable nodes. If there are only reachable nodes in the network, the \(FindNode\) operation can be used to achieve peer discovery. However, there are reachable nodes \(\mathcal{R}\) and unreachable nodes \(\mathcal{U}\) in the network, and both \(r_{i}\) and \(u_{i}\) have the same address format, so it is impossible to make a distinction in the address. So we want to implement a generalized algorithm that, given an address of \(c_{i}\), without knowing the node \(n_{i}\)_is_\(r_{i}\) or \(n_{i}\)_is_\(u_{i}\), the routing connection of this node can be obtained according to Algorithms 3 and 4. When a node in the network wants to find a node of unknown type based on NodeID, assuming that it does not store this node and this node's cache in its own k-bucket, it first finds the nearest \(\alpha\) nodes to this point in its own k-bucket. Then send \(FindPeers()\) requests to each of these nodes based on their \(<NodeID,IP,Port>\) and ask these nodes to query the target node for information. When the result is received, it updates its own k-bucket based on the result. If the \(NodeID\) to be looked up is still not in the result after the request is sent for each node, then the process is looped. In the current state, find the nearest \(\alpha\) nodes to this point in its own k-bucket again and send a request query to each of them. When the target node is found, it is determined whether the target node is a reachable node, if it is then it is directly connected based on the \(<NodeID,IP,Port>\) of the node and then the transmission channel is established. If it is an unreachable node, then it is necessary to first establish a connection with the node directly connected to this node, and then use the method in the next section to establish a data transmission channel with the unreachable node. Then, the nearest \(\alpha\) node in the k-bucket is added to this node to the cache using the \(addkbucketUbuff(. )\) function. ```
Input:\(NodeID\) of the node to look up Output: Session connected to the lookup node
1 whileresults not has the target \(NodeID\)do
2 Neighbors\(\leftarrow FindKbucketna(NodeID)\); // Find the nearest \(\alpha\) node to own in the k-bucket
3 foreach\(e\) in Neighborsdo
4\(results\gets FindPeers(NodeID)\); // Implemented in Algorithm 4\(updateKbucket(results)\);
5 ifresults has the target \(NodeID\)then
6 ifNtype is reachable nodethen
7\(session\leftarrow connectNode(NodeID,IP,Port)\);
8
9 else
10\(connectPreNode(NodeID_{e},IP,Port)\);
11 addkbucketUbuff\((NodeID_{Ut},NodeID_{R},IP_{R},Port_{R})\);
12\(session\leftarrow estConForUnreach(NodeID)\); // Establish connections for unreachable nodes through reachable nodes. It will be implemented in the next section. 13
14 end if
15 break;
16
17 end if
18
19 end if
20
21 end if returnsession;
```  
**Algorithm 3**Nodes (reachable nodes \(\mathcal{R}\), unreachable nodes \(\mathcal{U}\)) lookup (discovery) algorithm  
```
Input:\(NodeID\) of the node to look up Output: NodeID and more information about the node to be found or \(\alpha\) logical distance to the nearest result
1\(resultFir\gets lookFirkBuc()\);
2 ifresultFir is Truethen
3 return\(<NodeID,IP,Port>\);
4\(resultSec\gets lookSecKbuck()\);
5 ifresultSec is ownthen
6 returnthis node \(<NodeID,IP,Port>\);
7
8 else
9 returnthe own \(<NodeID,IP,Port>\);
10 // result is catch, need to return the owner information
11
12 end if
13
14 Neighbors\(\leftarrow FindKbucketna(NodeID)\); // Find the nearest \(\alpha\) node to own in the k-bucket returnNeighbors
```  
**Algorithm 4**FindPeers() procedure in reachable nodes  
The \(FindPeers()\) function in the reachable nodes is implemented in Algorithm 4. When a reachable node receives a request from another node, it first queries its first k-bucket and returns the information of the target node directly if there is a target node.